A Lucene.NET index physically contains one or more segments, each of which is its own index and holds a subset of the overall indexed content. As documents are added to the index, new segments are created as index writer's flush-buffered content into the index's directory and file structure. Over time this fragmentation will cause searches to slow, requiring a merge/optimization to be performed to regain performance.
Index optimization is accomplished by calling the
Optimize method on an instance of
IndexWriter. The example for this recipe demonstrates the use of the
Optimize method to clean up the storage of the index data on the physical disk. The general steps in the process ...