Class IndexRearranger

java.lang.Object
org.apache.lucene.misc.index.IndexRearranger

public class IndexRearranger extends Object
Copy and rearrange index according to document selectors, from input dir to output dir. Length of documentSelectors determines how many segments there will be.

Rearranging works in 3 steps: 1. Assume all docs in the original index are live and create the rearranged index using the segment selectors. 2. Go through the rearranged index and apply deletes requested by the deletes selector. 3. Reorder the segments to match the order of the selectors and check the validity of the rearranged index.

NB: You can't produce segments that only contain deletes. If you select all documents in a segment for deletion, the entire segment will be discarded.

Example use case: You are testing search performance after a change to indexing. You can index the same content using the old and new indexers and then rearrange one of them to the shape of the other. Using rearrange will give more accurate measurements, since you will not be introducing noise from index geometry.

TODO: another possible (faster) approach to do this is to manipulate FlushPolicy and MergePolicy at indexing time to create small desired segments first and merge them accordingly for details please see: https://markmail.org/message/lbtdntclpnocmfuf

WARNING: This API is experimental and might change in incompatible ways in the next release.