O'Reilly logo

Hibernate Search by Example by Steve Perkins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defragmenting an index

Changes to a Lucene index slowly make it less efficient over time, in the same way that a hard drive can become fragmented. When new entities are indexed, they go into a file (called a segment) that is separate from the main index file. When an entity is deleted, it actually remains in the index file and is simply marked as inaccessible.

These techniques help Lucene to keep its indexes as accessible for queries as possible, but it leads to slower performance over time. Having to open multiple segment files is slow, and can run up against operating system limits on the number of open files. Keeping deleted entities in the index makes the files more bloated than they need to be.

The process of merging all of these segments, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required