Phrase Matching with Term Positions
A phrase query normally needs terms in the required relative positions, not merely each term somewhere in the document.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace adjacent tokens
If data occurs at positions 1 and 5 and model at 2, “data model” matches positions 1 and 2. If model occurs only at position 3, both terms are present and the exact phrase is absent. See sequence contiguity.
Choose which positions count
Tokenization can remove punctuation or special terms. Keep position increments consistent with the intended phrase semantics. Tokenization supplies those units.[1]
Check the positions of adjacent terms
Document one contains “rail map” at positions zero and one. Document two contains “rail route map” with rail at zero and map at two. Both contain the terms, but only the first satisfies an exact adjacent phrase under this tokenization. See substrings and subsequences.
D1 positions: rail 0, map 1 → exact phrase
D2 positions: rail 0, map 2 → term match only
Match condition: some map position equals rail position plus 1
Keep token removal consistent with phrase semantics
Removing stop words can change adjacency if position increments are compressed. Document how a quoted phrase behaves across such words and field boundaries. Test a phrase near punctuation.