 <p>The <a href="http://wiki.apache.org/solr/UpdateXmlMessages#A.22commit.22_and_.22optimize.22" rel="nofollow noreferrer">documentation</a> 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. </p>