Commit, rollback, and index optimization
The commitWithin
parameter that we have been passing as arguments to our
addDocument()
function specifies the time for the commit to happen for this add document operation. This leaves the control of when to do the commit to Solr itself. Solr optimizes the number of commits to a minimum while still fulfilling the update latency requirements.
The rollback option is exposed via the
addRollback()
function. Rollback can be done since the last commit and before current commit. Once a commit has been done, the changes cannot be rolled back.
$rollbackQuery = $client->createUpdate(); $rollbackQuery->addRollback();
Index optimization is one of the tasks that is not necessarily required. But an optimized index has better performance than a non-optimized index. To optimize an index using the PHP code, we can use the addOptimize(boolean $softCommit, boolean $waitSearcher, int $maxSegments)
function. It has parameters to enable soft commit, wait until a new...