Phrase and Proximity Queries

Matching words in sequence or near each other. Why document-level postings cannot answer phrase queries, biword indexes and their false positives measured on Cranfield, positional indexes, the positional merge and the linear-time window algorithm traced position by position, a six-word phrase, distance, sentence and paragraph operators each worked to the end, the smallest window as a proximity measure, and combined indexes. Worked problems on biword false positives and on phrase and proximity queries over positional postings.

Phrase and proximity queries need word positions: postings that record only which documents contain a term cannot tell a warming climate from the climate warms. On the 1,400 Cranfield abstracts, a biword index has 75,583 distinct biwords against 7,472 distinct words, and run on all 157,304 three-word phrases of the collection it returns 27.6 percent false positives, 98.4 percent of them from phrases containing a stop word. A positional index answers phrase and proximity queries exactly, by merging sorted position lists within each document, and holds about twice as many entries as document-level postings on Cranfield (the course text estimates two to four times the size). Sentence and paragraph operators run the same merge on sentence and paragraph numbers.

Two of the thesis student's Arctic sentences contain both warm and climat: document 2 says a warming climate, document 1 the climate warms. The query warm AND climat, answered by intersecting postings lists, returns both, though only document 2 contains the phrase. Likewise, The inventor Stanford Ovshinsky never went to university satisfies stanford AND university without being about the institution (Manning, Raghavan, and Schütze, 2008, §2.4). The Boolean model as described so far cannot tell the difference, because its postings record which documents contain each term, not where. What must the index store to answer a query about word order? It must store where each term occurs: the position of every occurrence, in every document.

Phrase queries, usually marked with quotation marks, ask for words in a specific sequence. Proximity queries ask for words within some distance of each other, in either order. Many queries name things, such as New York or Department of Defense, whose words mean something only together. The course text reports that as many as 10 percent of web queries are phrase queries, and that many more are phrases in effect, such as names typed without quotation marks (Manning, Raghavan, and Schütze, 2008, §2.4). The inverted index article showed what a positional posting looks like; this article is the home of the algorithms that use one.

First we index word pairs and measure their size and false positives on a real collection. Then we store positions instead, and trace the merge and window algorithms that use them on phrases, on distances in words, and on sentences and paragraphs. Next we weigh the cost of positions and see how production systems combine the two approaches. Worked problems close the article.

Biword indexes

Can word order be captured without changing what a posting holds? Partly. The simplest approach treats each pair of consecutive words as a single term. The text friends Romans countrymen produces the biwords friends romans and romans countrymen, each with its own postings list in the dictionary. A two-word phrase query becomes a single dictionary lookup.

A longer phrase is broken into overlapping biwords and evaluated as their conjunction. The query "stanford university palo alto" becomes

"stanford university" AND "university palo" AND "palo alto"

This can produce false positives. A document might contain stanford university in one paragraph, university palo in another, and palo alto in a third, without ever containing the four-word phrase. The documents retrieved must then be checked against their text to confirm that the full phrase occurs.

Example (two-word phrases are exact). A biword index built from consecutive words returns no false positive for a two-word phrase such as "warming climate". The phrase is a single biword, and its postings list holds exactly the documents where the two words are adjacent in that order. False positives need at least three words, split into biwords that can match in different places.

Biword indexes have two further costs. The dictionary grows enormously, since the number of distinct word pairs in a collection far exceeds the number of distinct words. And a biword index cannot answer proximity queries at all. One refinement indexes extended biwords, pairs of nouns separated by any number of function words, identified by part-of-speech tagging. Cost overruns on a power plant is then indexed as cost overruns, overruns power, and power plant, so queries match despite intervening words (Manning, Raghavan, and Schütze, 2008, §2.4.1). The approach is rarely used alone, but indexing selected word pairs survives as part of combined schemes, described below.

How large, and how wrong?

Both costs can be measured on a real collection. The Cranfield collection (Cleverdon, 1967) has 1,400 abstracts of aerodynamics papers. Tokenized into lowercase words, with no stop list and no stemming, it has:

Quantity Count
Tokens (word occurrences) 243,353
Distinct words 7,472
Distinct biwords 75,583
Distinct three-word phrases 157,304

The biword dictionary is ten times the size of the word dictionary, even for this small, specialized collection, and the dictionary of three-word phrases is twice as large again.

To measure false positives, every three-word phrase that occurs in the collection was run as a query in two ways: as the conjunction of its two biwords, and exactly. Summed over all 157,304 phrases, the biword conjunctions retrieve 298,298 documents, of which 216,055 contain the phrase. The other 82,243, 27.6 percent of what the biword index retrieves, are false positives.

Nearly all of them, 98.4 percent, come from phrases containing a stop word, which pairs with almost anything. of the results occurs in 26 abstracts, but of the and the results co-occur in 235. Phrases made only of content words fare far better, with 3.0 percent false positives, but are not immune. mach number range occurs in 31 abstracts, while mach number and number range co-occur in 36. (Stop words here are the 33-word list this site's search used in November 2026, when the figures were computed.) These figures come from tools/experiments/boolean/phrase_queries.py.

Positional indexes

A biword index grows large and still guesses. Is there an exact answer at a predictable cost? There is. The standard solution stores, in each posting, the positions at which the term occurs in the document. A positional index entry has the form

term: df
    docID: tf; position, position, ...
    docID: tf; position, position, ...

where the term frequency $\mathit{tf}$ is simply the number of positions listed. Consider three short documents, with positions counted in words from 1:

docID Text
1 to be or not to be that is the question
2 the question is to be decided by the board
3 be sure to read it to them and be kind

The positional postings for to and be are:

to:  doc 1: 1, 5    doc 2: 4    doc 3: 3, 6
be:  doc 1: 2, 6    doc 2: 5    doc 3: 1, 9
The three documents as numbered word positions, with to in solid boxes and be in dashed boxes. Solid green arrows mark the three occurrences of the phrase to be, where be sits exactly one position after to. Notice the dashed yellow arrow in document 3: it joins be at 1 and to at 3, two words apart in the wrong order, so it satisfies to /2 be but not the phrase.
The three documents as numbered word positions, with to in solid boxes and be in dashed boxes. Solid green arrows mark the three occurrences of the phrase to be, where be sits exactly one position after to. Notice the dashed yellow arrow in document 3: it joins be at 1 and to at 3, two words apart in the wrong order, so it satisfies to /2 be but not the phrase.

Answering a phrase query

To find "to be":

  1. Intersect the two terms' document lists, as in an ordinary AND, to find documents containing both terms: 1, 2, and 3.
  2. In each such document, look for a position of be exactly one greater than a position of to.

In document 1, to at 1 is followed by be at 2, and to at 5 by be at 6, giving two occurrences. In document 2, to at 4 is followed by be at 5. In document 3, to appears at 3 and 6 and be at 1 and 9, never adjacent. The answer is documents 1 and 2. Unlike the biword approach, this result is exact, with no false positives to filter.

The same check settles the Arctic sentences, with positions counting every word. In document 2, warm is at 2 and climat at 3, so the phrase matches. In document 1, climat is at 8 and warm at 9: the right distance in the wrong order.

How should step 2 compare the positions? It is itself a merge. Both position lists are sorted, so instead of comparing every pair, the algorithm walks them together, comparing each position of be with the current position of to plus one. Manning, Raghavan, and Schütze (2008, Figure 2.11) give longer lists for one document, number 4:

to:  doc 4: 8, 16, 190, 429, 433
be:  doc 4: 17, 191, 291, 430, 434
Step to at wanted be at be at Action
1 8 9 17 17 > 9: advance to
2 16 17 17 match: phrase at 16
3 190 191 191 match: phrase at 190
4 429 430 291 291 < 430: advance be
5 429 430 430 match: phrase at 429
6 433 434 434 match: phrase at 433

Six comparisons find all four occurrences, against 25 for comparing all pairs. The cost is linear in the lengths of the two position lists, as for the docID merge.

Longer phrases extend the check with offsets. For "to be or not to be", the book's Example 2.1 looks for a to at some position $p$, be at $p + 1$, and the second to and be at $p + 4$ and $p + 5$. In document 4 only $p = 429$ qualifies: to at 429 and 433, be at 430 and 434. It is a candidate, confirmed only if or and not occupy positions 431 and 432. The textbook's figure gives no postings for those two words, so the example cannot be finished on document 4. The three-document collection can finish it.

A six-word phrase, worked to the end

Document 1 is to be or not to be that is the question, so the query "to be or not to be" should return document 1, with the phrase starting at position 1. The phrase has four distinct terms, and their positional postings in the three documents are:

to:   doc 1: 1, 5    doc 2: 4    doc 3: 3, 6
be:   doc 1: 2, 6    doc 2: 5    doc 3: 1, 9
or:   doc 1: 3
not:  doc 1: 4

A phrase starting at position $p$ needs to at $p$ and $p + 4$, be at $p + 1$ and $p + 5$, or at $p + 2$ and not at $p + 3$. The evaluation has two stages.

  1. Documents. Intersect the four document lists, shortest first: or and not each occur in document 1 only, and the lists of to and be both contain document 1. The intersection is document 1, and documents 2 and 3 are never examined for positions.
  2. Positions. Start from the rarest term. In document 1, or occurs once, at position 3. The phrase puts or at $p + 2$, so the only possible start is $p = 3 - 2 = 1$. Check each other term at the position the phrase requires:
Term Required position Positions in document 1 Present?
to $p = 1$ 1, 5 yes
be $p + 1 = 2$ 2, 6 yes
or $p + 2 = 3$ 3 yes (the starting point)
not $p + 3 = 4$ 4 yes
to $p + 4 = 5$ 1, 5 yes
be $p + 5 = 6$ 2, 6 yes

All six checks succeed, so the answer is document 1, with one occurrence at position 1.

Starting from the rarest term is the reasoning of optimizing Boolean queries applied to positions. The single position of or gave one candidate start, and each remaining check was one lookup in a sorted position list. Starting from to would have given two candidate starts, 1 and 5. The second fails at once, because the phrase would need be at 6, which is there, and then or at 7, which is not. In a long document, to has hundreds of positions and or a handful, and the saving is in proportion. The script's phrase function works this way. The script checks it against a scan of the text in both directions: for every sequence of one to three words of the collection's vocabulary, whether it occurs or not, the function returns exactly the starting positions the scan finds in each of the three documents.

Proximity queries

What if the words need only be near each other? A proximity operator relaxes adjacency to a distance. Writing to /k be for "to within $k$ words of be, in either order", the check in each document becomes $|\,p_{\text{be}} - p_{\text{to}}\,| \le k$. For to /2 be, documents 1 and 2 match as before. Document 3 now matches too, because be at position 1 is two words before to at position 3.

Worked to the end on the three documents, the query returns these pairs of positions (to, be) for $k = 1$, 2 and 3:

Query Document 1 Document 2 Document 3 Documents returned
to /1 be (1, 2), (5, 6) (4, 5) none 1, 2
to /2 be (1, 2), (5, 6) (4, 5) (3, 1) 1, 2, 3
to /3 be (1, 2), (5, 2), (5, 6) (4, 5) (3, 1), (6, 9) 1, 2, 3

In document 3 the smallest distance between a to (at 3 or 6) and a be (at 1 or 9) is $|3 - 1| = 2$, so the document enters at $k = 2$. At $k = 3$ a second pair appears there, to at 6 with be at 9, and document 1 gains the pair (5, 2): the second to is three words after the first be. The set of documents stops growing at $k = 2$, but the list of matches does not.

Example (the proximity query on the Arctic sentences). Both Arctic sentences match warm /1 climat. The operator ignores order, and in each document the terms are one position apart. The proximity query gives back the ambiguity that the phrase query removed.

The algorithm for comparing the position lists within a document is again a merge. Here is the idea in one sentence: keep a window of the second term's positions that lie within $k$ of the current position of the first, adding new positions as the first pointer advances and dropping those that fall behind (Manning, Raghavan, and Schütze, 2008, §2.4.2, Figure 2.12). Because both lists only move forward, each position enters and leaves the window once. Apart from the cost of reporting matches, this takes time linear in the lengths of the two position lists.

def window_proximity(p1, p2, k):
    """Pairs (a, b) of positions, a from p1 and b from p2, with |a - b| <= k."""
    out, window, j = [], [], 0
    for a in p1:
        while j < len(p2) and p2[j] <= a + k:   # admit positions up to a + k
            window.append(p2[j])
            j += 1
        while window and window[0] < a - k:     # drop positions more than k behind
            window.pop(0)
        out += [(a, b) for b in window]
    return out

For to /3 be in document 4, the window after each position of to is:

to at Window of be positions within 3 Pairs reported
8 empty (17 is too far ahead) none
16 17 (16, 17)
190 191 (17 dropped) (190, 191)
429 430 (191 dropped; 291 admitted and dropped) (429, 430)
433 430, 434 (433, 430), (433, 434)

Position 430 stays in the window from 429 to 433 because it is within 3 of both. That is how one occurrence of be can pair with two of to, and why the window holds a list, not a single position. (A production version would use a deque or an index into p2 rather than pop(0).) The script checks this function against a brute-force comparison of all pairs on 500 random cases.

The same function produces the table of the three documents above. In document 3, with to at 3 and 6 and be at 1 and 9:

Query to at Admitted Dropped Window Pairs reported
to /2 be 3 1 (at most $3 + 2$) none 1 (3, 1)
to /2 be 6 none (9 is more than $6 + 2$) 1 (less than $6 - 2$) empty none
to /3 be 3 1 none 1 (3, 1)
to /3 be 6 9 (at most $6 + 3$) 1 (less than $6 - 3$) 9 (6, 9)

A straightforward version, which compares all pairs and is adequate when position lists are short, is:

def positional_intersect(post1, post2, k, ordered=False):
    """post1, post2: {docID: sorted positions}. Returns (docID, pos1, pos2) matches."""
    matches = []
    for doc in sorted(post1.keys() & post2.keys()):
        for p1 in post1[doc]:
            for p2 in post2[doc]:
                distance = p2 - p1
                if (ordered and 0 < distance <= k) or (not ordered and abs(distance) <= k):
                    matches.append((doc, p1, p2))
    return matches

With ordered=True and k=1, it answers a phrase query, and with ordered=False it answers a proximity query.

Sentence and paragraph operators

Professional query languages offer richer proximity operators. Legal search systems, for example, distinguish "within $k$ words" from "in the same sentence" (/s) and from "in the same paragraph" (/p) (Manning, Raghavan, and Schütze, 2008, §1.4). Sentence and paragraph operators require the index to record sentence and paragraph boundaries, or to store positions as (paragraph, sentence, word) triples. Boolean search in practice shows how these operators are used. Here we evaluate them.

The three documents are one sentence each, so they cannot show a sentence boundary. Join them instead into a single document of two paragraphs. The first paragraph has two sentences and the second has one, and words are numbered from 1 to 29 through the whole document:

Paragraph Sentence Words Text
1 1 1 to 10 to be or not to be that is the question
1 2 11 to 19 the question is to be decided by the board
2 3 20 to 29 be sure to read it to them and be kind

Each position in a posting is now a triple (paragraph, sentence, word):

question:  (1, 1, 10)  (1, 2, 12)
decided:   (1, 2, 16)
board:     (1, 2, 19)
kind:      (2, 3, 29)

The check for /s compares the sentence numbers of two positions, and the check for /p compares their paragraph numbers. The word numbers play no part.

Query Check Matching pairs of word positions Result
question /s board same sentence number (12, 19), both in sentence 2 match
question /5 board word positions differ by at most 5 none: $19 - 12 = 7$ and $19 - 10 = 9$ no match
question /p board same paragraph number (10, 19) and (12, 19), all in paragraph 1 match
board /p kind same paragraph number none: paragraphs 1 and 2 no match
board /10 kind word positions differ by at most 10 (19, 29): $29 - 19 = 10$ match

The table shows that neither kind of operator can stand in for the other. Question and board share a sentence although they are seven words apart, so /s finds what /5 misses. Board and kind are ten words apart but in different paragraphs, so /10 accepts what /p rejects. A sentence is a unit of meaning, and a count of words only approximates it.

The algorithm is the docID merge once more. Within a document, each term's triples are sorted, so their sentence numbers are non-decreasing. Walk the two lists together. When the sentence numbers at the two pointers differ, advance the pointer at the smaller one, since that sentence cannot contain the other term. When they agree, report every pair of positions in that sentence and move both pointers past it. For question /s board, the pointers start at sentences 1 and 2. Sentence 1 is smaller, so question advances to (1, 2, 12). The sentences now agree, and the pair (12, 19) is reported. For /p the same walk compares paragraph numbers. The script runs this merge for every pair of words in the document, at both levels, and checks it against a comparison of all pairs.

An index that stores plain word positions can answer the same queries from a sorted list of the positions at which sentences begin, here 1, 11 and 20, and of paragraphs, here 1 and 20. A binary search of that list turns a word position into its sentence number: position 12 lies between 11 and 20, so it is in sentence 2.

Positions and stop words

What happens to positions when stop words are removed? They must still be counted as if the words were there, or phrases containing them will match the wrong text. Counting the original word positions lets "department of defense" be answered as department at $p$ and defense at $p + 2$, with the gap standing for the removed of. The check never looks at position $p + 1$, so department for defense, or any other word between the two, would match too.

This site's own search goes one step further. It counts positions with stop words included and also keeps the stop words' own positions, which only phrase matching reads. So "department of defense" needs of itself at $p + 1$, and department for defense does not match (How This Search Works gives the details).

The cost of positions

Exact answers have a price. A positional index is much larger than a document-level one, because it stores an entry for every occurrence of every term rather than one per document. Its size grows with the total length of the collection, not with the number of distinct term-document pairs. In Cranfield, the 1,400 abstracts produce 122,935 document-level postings and 243,353 positions, about twice as many.

The ratio is the average number of times a term repeats within a document, and it rises with document length. Cranfield's abstracts average 174 words, while books and long filings run to tens of thousands. Positions are stored as gaps between successive occurrences and compressed with the same variable-length codes used for docIDs. Even so, Manning, Raghavan, and Schütze (2008, §2.4.2) estimate that a positional index is two to four times as large as a non-positional one. Processing is also more expensive: a phrase query containing a frequent word, such as "the who", must examine the long position lists of the.

Combining the approaches

Must a system choose between biwords and positions? It need not. Williams, Zobel, and Bahle (2004) combined the approaches. Their scheme adds two partial structures to a positional index:

  • a phrase index of phrases that are frequent in queries;
  • a nextword index that records, for each of the most common words, the words that follow it, so that phrases containing common words do not require their long position lists.

On a realistic mix of web queries, the combined index answered phrase queries in about a quarter of the time of a positional index alone, at the cost of about a quarter more space. Indexing common-word pairs, as described in stop words, applies the same idea specifically to phrases that contain stop words. The Cranfield measurement shows why that targeting works: the biword false positives and the long position lists are both concentrated in phrases with common words.

Positions beyond Boolean queries

Positional information is also valuable for ranking. Documents in which the query terms appear close together are more likely to be relevant than documents in which they are scattered, and retrieval models incorporate term proximity as a ranking signal for this reason (Tao and Zhai, 2007), as term dependence models do with ordered and unordered windows. A dense retriever that encodes each passage as one vector keeps no positions at all, and Limits of Single-Vector Retrieval counts queries whose exact tokens decide relevance, quoted phrases among them, as a case where a lexical ranker is the better first stage. Positions also make it possible to generate query-dependent snippets and to highlight the matched terms in results. A positional index built to answer phrase queries thus serves several later stages of a search engine. That is a reason to store positions even where only a minority of queries are quoted phrases.

The simplest proximity measure is the one the course text describes: the width $\omega$, in words, of the smallest window of the document that contains every query term (Manning, Raghavan, and Schütze, 2008, §7.2.2). The text's illustration is a document consisting of the quality of mercy is not strained and the query strained mercy: the smallest window runs from mercy at position 4 to strained at position 7, so $\omega = 4$.

Example (the smallest window on the three documents). For the free-text query to be question, document 2 has the tighter window, $\omega = 4$ against $\omega = 6$ in document 1, and document 3 has none. The postings are to 1, 5, be 2, 6 and question 10 in document 1, and to 4, be 5 and question 2 in document 2. Document 3 lacks question.

  • In document 1 every window must contain position 10, the only question. The nearest to before it is at 5 and the nearest be at 6, so the smallest window is positions 5 to 10, six words: to be that is the question.
  • In document 2 every window must contain position 2. The only to is at 4 and the only be at 5, so the smallest window is positions 2 to 5, four words: question is to be.

A Boolean AND treats the two documents alike. A ranking function that rewards a small $\omega$ puts document 2 first. The widths come from a search over all windows in the script, which also reproduces the textbook's $\omega = 4$.

Worked problems

Problems 1 and 2 are Exercises 2.8 and 2.9 of the course text (Manning, Raghavan, and Schütze, 2008), restated in our own words. Problem 3 is posed here on the three-document collection. The script checks every answer.

Problem 1. Assume a biword index. Give an example of a document that is returned for the query "New York University" although it does not contain the phrase.

Solution. The index evaluates the query as "new york" AND "york university". Any document that contains both biwords in different places is returned. One such document is

She left New York to teach at York University in Toronto.

It contains New York at words 3 and 4 and York University at words 8 and 9, so both biword postings lists include it. The three words New York University never occur in a row: the York that follows New is followed by to, and the York that precedes University is preceded by at. The document is a false positive, and only a check of its text, or a positional index, can reject it.

Problem 2. A positional index holds these postings for three documents, in the form term: document: positions:

angels:  2: 36, 174, 252, 651      4: 12, 22, 102, 432         7: 17
fools:   2: 1, 17, 74, 222         4: 8, 78, 108, 458          7: 3, 13, 23, 193
fear:    2: 87, 704, 722, 901      4: 13, 43, 113, 433         7: 18, 328, 528
in:      2: 3, 37, 76, 444, 851    4: 10, 20, 110, 470, 500    7: 5, 15, 25, 195
rush:    2: 2, 66, 194, 321, 702   4: 9, 69, 149, 429, 569     7: 4, 14, 404
to:      2: 47, 86, 234, 999       4: 14, 24, 774, 944         7: 199, 319, 599, 709
tread:   2: 57, 94, 333            4: 15, 35, 155              7: 20, 320
where:   2: 67, 124, 393, 1001     4: 11, 41, 101, 421, 431    7: 16, 36, 736

Which documents match (a) "fools rush in" and (b) "fools rush in" AND "angels fear to tread"?

Solution. (a) Documents 2, 4 and 7. The phrase needs fools at some position $p$, rush at $p + 1$ and in at $p + 2$. For each position of fools, look up $p + 1$ in the positions of rush, and if it is there, $p + 2$ in the positions of in:

Document fools at $p$ rush at $p + 1$? in at $p + 2$? Phrase at
2 1 2, yes 3, yes 1
2 17, 74, 222 18, 75, 223: no
4 8 9, yes 10, yes 8
4 78, 108, 458 79, 109, 459: no
7 3 4, yes 5, yes 3
7 13 14, yes 15, yes 13
7 23, 193 24, 194: no

The phrase occurs once in document 2, once in document 4 and twice in document 7.

(b) Document 4 only. The second phrase needs angels at $q$, fear at $q + 1$, to at $q + 2$ and tread at $q + 3$.

  • Document 2: fear would have to be at 37, 175, 253 or 652. Its positions are 87, 704, 722 and 901. No match.
  • Document 4: angels at 12 is followed by fear at 13, to at 14 and tread at 15. The phrase occurs at 12. (Angels at 432 is followed by fear at 433, but to is not at 434.)
  • Document 7: angels at 17 is followed by fear at 18, but to is not at 19. No match.

So "angels fear to tread" matches document 4 alone, and the conjunction of the two phrases is the intersection of $\{2, 4, 7\}$ and $\{4\}$, which is document 4. There the text runs fools rush in where angels fear to tread from position 8 to 15, with where at 11.

Problem 3. On the three-document collection, describe the documents returned by to /k be and by question /k be for every positive whole number $k$.

Solution. to /k be returns documents 1 and 2 for $k = 1$ and all three documents for every $k \ge 2$. question /k be returns nothing for $k \le 2$, document 2 for $k = 3$, and documents 1 and 2 for every $k \ge 4$.

A document matches w1 /k w2 exactly when $k$ is at least the smallest distance between a position of the first word and a position of the second. So each document has a threshold, and the answer changes only at the thresholds.

Document Positions Smallest distance to, be Smallest distance question, be
1 to 1, 5; be 2, 6; question 10 $\lvert 1 - 2 \rvert = 1$ $\lvert 10 - 6 \rvert = 4$
2 to 4; be 5; question 2 $\lvert 4 - 5 \rvert = 1$ $\lvert 2 - 5 \rvert = 3$
3 to 3, 6; be 1, 9 $\lvert 3 - 1 \rvert = 2$ no question

For to and be the thresholds are 1, 1 and 2, which gives the two answers stated. For question and be they are 4 and 3, and document 3 can never match, which gives the three answers stated. Raising $k$ never removes a document, so each query's answers form a chain that grows with $k$ and then stays fixed.

What we have learned

Document-level postings cannot tell warming climate from climate warms. On Cranfield, a biword index had ten times the dictionary and returned 27.6 percent false positives on three-word phrases. A positional index answers phrase and proximity queries exactly, with a merge of position lists inside each document, at about twice the postings. Sentence and paragraph operators run the same merge on sentence and paragraph numbers.

Every query so far arrived already structured. The next article, Parsing and Evaluating Boolean Queries, shows how a typed string such as paper OR date AND book becomes a tree that an index can evaluate.

References

  • Cleverdon, C. W. (1967). The Cranfield tests on index language devices. Aslib Proceedings, 19(6), 173–194. record · 11 pages
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, sections 1.4, 2.4 and 7.2.2, Figures 2.11 and 2.12, and Example 2.1. Cambridge University Press. record · 102 pages
  • Tao, T., and Zhai, C. (2007). An exploration of proximity measures in information retrieval. In Proceedings of SIGIR 2007, 295–302. record
  • Williams, H. E., Zobel, J., and Bahle, D. (2004). Fast phrase querying with combined indexes. ACM Transactions on Information Systems, 22(4), 573–594. record

Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · 10 revisions