views:

70

answers:

1

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

A: 

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.

Pascal Dimassimo