AND Queries by Intersecting Postings
In a simple Boolean model, AND keeps documents appearing in every requested term's postings.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a two-term match
If databases maps to documents 1, 2, 6 and transactions maps to 2, 4, the intersection is document 2. This uses set intersection directly.
Check an absent term
If one posting list is empty, the combined result is empty. A ranker using optional terms follows a different matching contract. Inverted index construction describes the inputs to both approaches.[1]
Walk two sorted lists to identify shared documents
Suppose rail occurs in documents one, three and seven. Map occurs in two, three and six. Comparing current IDs and advancing the smaller discards an ID that cannot appear later in the other list. Document three is the only match. See front-and-back scan proofs.
Compare 1 and 2 → advance first
Compare 3 and 2 → advance second
Compare 3 and 3 → emit 3
Remaining lists share nothing
Handle repeated tokens and absent postings
A repeated search term may be simplified under pure set intersection. A missing term gives an empty AND result. Validate the sorted-posting assumption and test intersecting at the final pair.