The order in which segments get searched depends on the order of a List that IndexWriter internally maintains (IndexWriter.segmentInfos.segments).
When segments get flushed, they are appended to the end of this list of segments. So more recent segments get However when segments get merged together, the new (merged) segment takes the smallest index of the merged segments, so even though this merged segment is the most recent one, it could be at any index within SegmentInfos (which defines the order in which segments get searched today). A benefit of this approach is that if you have an append-only workload and a merge policy that only merges adjacent segments like LogDocMergePolicy and LogByteMergePolicy, then your global doc IDs are stable over time. However beware that this is not true with TieredMergePolicy, which may occasionally merge non-adjacent segments. On Fri, Apr 16, 2021 at 7:22 AM nic k <[email protected]> wrote: > hello i have a question, so im sending u an e-mail > > when searching in lucene, i wonder if it reads from the oldest segment or > the most recently created segment > > when i test it, i think it reads the oldest file first, but i ask for > conviction, not conjecture > please im looking around and i cant figure it out so i ask > thank u > -- Adrien
