Managing your index

Committing changes

We mentioned the use of commit() above. It takes three optional arguments:

  • waitSearcher
  • expungeDeletes
  • softCommit

See for details.


After updating an index with new data, it becomes fragmented and performance suffers. This means that you need to optimize the index. When and how often you do this is something you need to decide on a case by case basis. If you only add data infrequently, you should optimize after every new update; if you trickle in data on a frequent basis, you need to think more about it. See

Either way, to optimize an index, simply call:


A Solr optimize also performs a commit, so if you’re about to optimize() anyway, you can leave off the preceding commit(). It doesn’t particularly hurt to do both though.

optimize() takes two optional arguments:

  • waitSearcher
  • maxSegments

See for details.


If you haven’t yet added/deleted documents since the last commit, you can issue a rollback to revert the index state to that of the last commit.


Table Of Contents

Previous topic

Deleting documents

Next topic

Contributing to Sunburnt

This Page