I am using the Solr-php-client to communicate with Solr, via php.
This piece of code triggers the solr optimize command:
$solr->optimize();
I wonder if there is any method to know for sure that the optimization is done?
This is all because I have an administrations page on my website where I manually once a day must optimize the Solr index, but I have difficulty writing this code.
Currently I have a simple form with a submit button which triggers the optimize() command, but I must somehow confirm that the optimize has taken place, which is the problem here.
Do you know of any method to confirm an optimization in Solr?
Thanks
The documentation for the Optimize command specifies that, by default, the command will block until all changes are written to disk and that the new searcher is available. So if you keep those default values, when the command returns, you can consider the optimize done. Note that, depending on the number of segments you currently have and to how many you want to go down to, the command can block for a long time. I have seen optimize taking up to an hour to complete.
The easiest way is to start optimize from the Solr console, there's an "optimize now" button in the Overview section of your collection. If you refresh this screen, you will see the memory used growing until the it doubles, then the status optimized is ticked and the "optimize now" button disapear.
NB: You must have enough free disk space to complete the Optimise or it will fail without notice or error message.
This doesn't directly answer your question, but that's another way to deal with solr instance optisation. So I hope it will help.