Boolean Search in Practice

Where Boolean retrieval is used today and how it has been extended. Professional query languages with truncation and proximity operators, the evidence comparing Boolean and ranked search, extended Boolean and fuzzy models that grade matches, with the p-norm's limit derived and five documents ranked at several values of p, required, filter, prohibited and optional clauses in modern engines, and the implicit AND of web search. Worked problems on a Westlaw query, p-norm rankings with and without query weights, and clause-based queries.

Professional services such as Westlaw extend Boolean queries with truncation (liab!), proximity (/s, /p), fields and phrases, which trained searchers keep because the search is exact and can be reported and rerun. Yet ranked natural-language queries beat expert Boolean queries on average on legal collections (Turtle, 1994), and Boolean searchers found about 20 percent of the relevant documents while believing they had found at least 75 percent (Blair and Maron, 1985). The p-norm (Salton, Fox, and Wu, 1983) grades Boolean matches: AND and OR are both the average of the weights at $p = 1$ and tend to their minimum and maximum as $p \to \infty$. Lucene's clause kinds and web search's implicit AND keep Boolean logic as a filter, and rank within it.

A lawyer looking for cases about whether a host is liable for injuries caused by a drunk guest might type, into a legal research service,

host! /p (responsib! liab!) /p (intoxicat! drunk!) /p guest

This is a Boolean query in the language of Westlaw's "terms and connectors" search (Manning, Raghavan, and Schütze, 2008, §1.4, Example 1.1), built from the parts of the Boolean model. Why do trained searchers still write queries like this, decades after ranked retrieval became the default, and what has become of Boolean search elsewhere? They write them because such a query states exactly what is retrieved and can be reported and rerun. Elsewhere, Boolean search has become the filter that ranked systems apply before they rank.

Start with the syntax. The ! truncates a word, so liab! matches liable and liability. A space between words means OR, not AND. /p requires its operands to appear in the same paragraph, and /s in the same sentence. Read piece by piece:

Part Meaning
host! any word beginning host: host, hosts, hosted, but also hostage and hostile, which the query accepts too; requiring the other terms in the same paragraph makes such false matches rare
/p the terms on either side must occur in the same paragraph
(responsib! liab!) responsib- OR liab-: responsible, responsibility, liable, liability
(intoxicat! drunk!) intoxicat- OR drunk-: intoxicated, intoxication, drunk, drunken
guest the word guest

Without the paragraph conditions, the query is a conjunction of four concepts, each written as an OR of variants: host* AND (responsib* OR liab*) AND (intoxicat* OR drunk*) AND guest. That is the conjunctive normal form expert searchers favor. The /p connectors then tighten each AND to co-occurrence within a paragraph. That requires a positional index that records paragraph boundaries. Every part of the query is under the searcher's control, and every retrieved case can be explained by the terms it matched. Such queries are written by trained professionals, often over many iterations.

First we look at the operators of professional query languages and the evidence comparing Boolean and ranked search. Next we derive the p-norm, which grades a Boolean query's matches, and rank five documents with it. Then we see how modern engines keep Boolean logic as a filter. Worked problems close the article.

Professional query languages

What does an expert need beyond AND, OR, and NOT? Commercial search services for law, medicine, patents, and news developed query languages that extend them with operators suited to expert searching:

  • Truncation and wildcards. employe! matches every word that begins with employe: employee, employees, employer, and employed. It does not match employment, whose seventh letter is m, not e. The shorter stem employ! takes in all five words. The searcher controls the conflation explicitly, instead of relying on a stemmer. A truncated term is evaluated through the dictionary. The words with a given prefix are next to each other in the sorted dictionary, so the system finds that range of terms and takes the union of their postings lists (Manning, Raghavan, and Schütze, 2008, §3.2). Wildcard Queries works that lookup and the indexes for other patterns.
  • Proximity. /3 (within three words), /s (same sentence), and /p (same paragraph) are stronger than AND and weaker than an exact phrase. All of them require a positional index, and the sentence and paragraph operators also require it to record sentence and paragraph boundaries.
  • Field restrictions. Searches can be limited to a case's title, its headnotes, the judge, or the date, or to a medical article's subject headings.
  • Phrases. Quotation marks require an exact sequence: "trade secret".

Two further queries from the same source show the style. For the need "requirements for disabled people to be able to access a workplace":

disab! /p access! /s work-site work-place (employment /3 place)

and for "legal theories involved in preventing the disclosure of trade secrets by employees formerly employed by a competing company":

"trade secret" /s disclos! /s prevent /s employe!

Example (a case the paragraph operator rejects). Suppose a case uses host and guest only in its opening paragraph and discusses intoxication and liability only in a later paragraph. The first query above does not retrieve it. Host never shares a paragraph with the liability words, so the first /p already fails. With AND in place of each /p, the query would retrieve it. Phrase and proximity queries evaluates /s and /p on positions step by step.

Queries like these take skill to write. A searcher who knows the vocabulary of the field and the operators of the system can retrieve a focused set of documents, and can document exactly what was searched. That is why, as search in professional domains describes, legal researchers, patent examiners, and systematic reviewers continue to prefer them.

Boolean or ranked?

Whether expert Boolean queries retrieve better results than ranked retrieval was debated for decades, and the evidence mostly favors ranking, with qualifications.

Turtle (1994) compared the two on legal collections. Experienced searchers wrote Boolean queries for a set of research problems. The same problems were expressed as natural-language descriptions and run through a ranked retrieval system. On average the ranked natural-language queries performed better than the expert Boolean queries, and the course text reports that they did so for the majority of the information needs (Manning, Raghavan, and Schütze, 2008, §1.4).

Blair and Maron's earlier study (1985) of a full-text litigation support system had shown that its Boolean searchers greatly overestimated their own recall. They believed their searches had found at least 75 percent of the relevant documents, when about 20 percent had been found. The experimental literature since TREC has generally found ranked retrieval more effective, on average, than unranked Boolean retrieval for typical information needs.

If ranking wins on average, why does Boolean search persist? The qualifications explain it:

  • Averages hide tasks where control and reproducibility matter more than average effectiveness, such as a systematic review that must report its search exactly.
  • Experts often use Boolean queries iteratively, inspecting results and refining the query, which a single-query comparison does not capture.
  • Many professional systems now combine the two, letting a Boolean query define the set of documents and ranking the documents within it.

Grading Boolean matches

The last of those qualifications suggests a middle path. Can a Boolean query keep its structure and still rank? Several models replace its yes-or-no answer with a score.

Fuzzy-set retrieval assigns each document a membership weight between 0 and 1 for each term, rather than simply 0 or 1. It evaluates AND as the minimum of its operands' weights and OR as the maximum (Kraft and Buell, 1983). A document strongly associated with every term of a conjunction scores high, and one weakly associated with any term scores low.

The extended Boolean model of Salton, Fox, and Wu (1983) interpolates between strict Boolean logic and the averaging of the vector space model. Here is the idea in one sentence: AND and OR become generalized means of the term weights, and a single parameter sets how strongly the mean attends to the worst or best weight. For term weights $w_1, \dots, w_n$ in $[0, 1]$ and a parameter $p \ge 1$, the p-norm scores are

$$\mathrm{sim}_{\mathrm{OR}} = \left(\frac{w_1^p + \dots + w_n^p}{n}\right)^{1/p}, \qquad \mathrm{sim}_{\mathrm{AND}} = 1 - \left(\frac{(1 - w_1)^p + \dots + (1 - w_n)^p}{n}\right)^{1/p}.$$

The parameter $p$ controls how strict the operators are. For a document containing one of two ANDed terms fully ($w_1 = 1$) and the other not at all ($w_2 = 0$):

$p$ AND score OR score
1 0.500 0.500
2 0.293 0.707
5 0.129 0.871
50 0.014 0.986

At $p = 1$, AND and OR are the same, both equal to the average of the weights, as in a vector space model. As $p$ grows, AND approaches the strict Boolean answer of 0 for a document missing a term, and OR approaches 1 for a document containing any term. In the limit $p \to \infty$, the p-norm operators become exactly the minimum and maximum of the fuzzy-set model. Intermediate values give partial credit. A document missing one term of a conjunction is ranked below one that has both, but above one that has neither.

The formal version. The limit follows from a short argument. Let $w_{\max}$ be the largest weight. Every term of the OR sum is at most $w_{\max}^p$, and at least one equals it, so

$$\frac{w_{\max}^p}{n} \le \frac{w_1^p + \dots + w_n^p}{n} \le w_{\max}^p, \qquad\text{hence}\qquad \frac{w_{\max}}{n^{1/p}} \le \mathrm{sim}_{\mathrm{OR}} \le w_{\max}.$$

As $p \to \infty$, $n^{1/p} \to 1$, so $\mathrm{sim}_{\mathrm{OR}} \to w_{\max}$. The AND formula applies the same mean to the complements $1 - w_i$, whose largest value is $1 - w_{\min}$, so $\mathrm{sim}_{\mathrm{AND}} \to 1 - (1 - w_{\min}) = w_{\min}$. Large $p$ makes the mean attend only to the extreme weight, which for AND is the worst-matched term.

Ranking five documents

The parameter $p$ changes rankings, not just scores: as it grows, a document that matches one term perfectly and the other not at all falls past documents that match both weakly. Take a query t1 AND t2 and five documents with these term weights:

Document $w_1$ $w_2$ Strict Boolean $p = 1$ $p = 2$ $p = 5$ $p = \infty$
A 1.0 1.0 match 1.000 1.000 1.000 1.000
B 0.8 0.6 match 0.700 0.684 0.650 0.600
C 1.0 0.0 no match 0.500 0.293 0.129 0.000
D 0.5 0.5 match 0.500 0.500 0.500 0.500
E 0.3 0.2 match 0.250 0.248 0.243 0.200

Strict Boolean retrieval returns A, B, D, and E as an unordered set and drops C, which lacks $t_2$ entirely. The p-norm ranks all five. At $p = 1$, C ties with D: a perfect match on one term and none on the other averages to the same 0.5 as a half match on both. At $p = 2$, C falls below D, and from about $p = 2.4$ on (by $p = 5$ in the table) it falls below E, a weak match on both terms. The parameter thus sets how heavily a missing term is penalized, from not at all ($p = 1$) to completely ($p = \infty$).

Example (equal weights give the same score for every $p$). Document D, with weight 0.5 on both terms, has an AND score of 0.5 at $p = 50$, as at every other $p$. Both complements are 0.5, so the mean inside the AND formula is $0.5^p$, its $p$-th root is 0.5 for every $p$, and the score is $1 - 0.5 = 0.5$. In general, if every weight equals $w$, the mean of the $p$-th powers of the complements is $(1 - w)^p$, its $p$-th root is $1 - w$, and the AND score is $w$. The OR score is $(w^p)^{1/p} = w$ as well. That is why D lies on every curve in the figure below.

For t1 OR t2 the movement is reversed. C rises from 0.500 at $p = 1$ to 0.871 at $p = 5$ and passes B, since one strong match is what OR rewards.

Curves along which a two-term AND (left) and OR (right) scores exactly 0.5, for p from 1 to infinity, with the five documents placed by their weights. At p = 1 both curves are the same diagonal. As p grows, the AND curve bends toward the corner at (0.5, 0.5), so documents near the axes, such as C, fall below it; the OR curve bends the other way, so C rises above it. D lies on every curve.
Curves along which a two-term AND (left) and OR (right) scores exactly 0.5, for p from 1 to infinity, with the five documents placed by their weights. At p = 1 both curves are the same diagonal. As p grows, the AND curve bends toward the corner at (0.5, 0.5), so documents near the axes, such as C, fall below it; the OR curve bends the other way, so C rises above it. D lies on every curve.

Points above and to the right of a curve score more than 0.5. The figure makes the geometry of the model visible. P-norm AND rewards balance across terms, and OR rewards the single best term, with $p$ controlling how strongly. All the scores in this section come from tools/experiments/boolean/pnorm.py.

The published model is more general than the formulas above: each query term can carry a weight of its own (Salton, Fox, and Wu, 1983). With query weights $a_1, \dots, a_n$, the two scores become

$$\mathrm{sim}_{\mathrm{OR}} = \left(\frac{a_1^p w_1^p + \dots + a_n^p w_n^p}{a_1^p + \dots + a_n^p}\right)^{1/p}, \qquad \mathrm{sim}_{\mathrm{AND}} = 1 - \left(\frac{a_1^p (1 - w_1)^p + \dots + a_n^p (1 - w_n)^p}{a_1^p + \dots + a_n^p}\right)^{1/p}.$$

Equal query weights cancel and give back the unweighted formulas. Unequal weights answer one of the Boolean model's weaknesses, that all terms count equally. Problem 3 below works an example.

In Salton, Fox, and Wu's experiments the model retrieved more effectively than strict Boolean queries, but it was rarely adopted in commercial systems. They tended to keep strict Boolean semantics for filtering and use separate functions for ranking.

Required and optional clauses

That separation of filtering from ranking is how most engines work today. Modern search libraries expose a practical descendant of these ideas. In Lucene and the engines built on it, a query is a combination of clauses, each marked as one of four kinds (Apache Software Foundation, 2023):

  • required (MUST): the clause must match, and its match contributes to the score;
  • filter (FILTER): the clause must match, like a required clause, but takes no part in scoring;
  • prohibited (MUST_NOT): the clause must not match, and it contributes nothing to the score;
  • optional (SHOULD): the clause should match, and adds to the score when it does.

Required, filter and prohibited clauses act as Boolean AND and AND NOT, defining which documents qualify. When a query has at least one required or filter clause, optional clauses do not restrict the set, unless a minimum number of them is required to match. Each one that matches adds to the document's score. A query made only of optional clauses behaves like an OR: a document must match at least one of them.

The filter clause is this article's subject in a single setting. It is a Boolean condition, evaluated exactly, kept apart from the scoring. A query can therefore combine an exact Boolean filter with a ranked preference. It might require a product category and exclude out-of-stock items with filter and prohibited clauses, and rank the rest by text relevance with required or optional ones. The Boolean model survives as the filter, and ranking operates within it.

What about the search box most people use? Web search engines present a single box, but a Boolean model has traditionally operated behind it. By default, a query of several words was treated as an AND, and the engine first looked for pages containing every word. That default was then relaxed in several ways:

  • A page can match a word it does not contain if the word appears in the anchor text of links pointing to it. Brin and Page (1998, §2.2) describe indexing the text of a link with the page the link points to, and the course text treats anchor text as part of the target page's index (Manning, Raghavan, and Schütze, 2008, §21.1.1).
  • Query words are expanded with variants: other inflections, spelling corrections, and synonyms (see how a web search engine answers a query).
  • If too few pages contain all the words, the engine relaxes the conjunction, accepting pages that contain most of them.

Most importantly, the matching pages are ranked, so the size of the result set no longer matters. The searcher reads the top results, not the whole set. That removes the feast-or-famine problem described in the Boolean retrieval model, which was the main difficulty of using Boolean systems. Explicit operators remain for those who want them: quotation marks for phrases, a minus sign for NOT, and restrictions such as site:. Few searchers use them (Manning, Raghavan, and Schütze, 2008, §1.4). This site's own search box follows the same pattern, as parsing and evaluating Boolean queries describes. Its free-text default is an OR rather than an AND: every word is optional, as with Lucene's optional clauses, + makes a word required and - prohibits it, and BM25F ranks the pages that match (How This Search Works). In effect, web search turned Boolean retrieval from the interface into an internal step. It selects candidates, and ranking decides what the user sees.

Worked problems

Problem 1 is Exercise 1.12 of the course text (Manning, Raghavan, and Schütze, 2008), restated in our own words. Problems 2 and 3 are posed here on the five documents of this article, and Problem 4 on the five-document postings of parsing and evaluating Boolean queries. The script checks every number.

Problem 1. Write a query in the Westlaw syntax described above that finds any of the words professor, teacher or lecturer in the same sentence as a form of the verb explain.

Solution.

professor teacher lecturer /s explain!

Three rules of the syntax produce it. A space between words means OR, so professor teacher lecturer matches any one of the three. The space binds more tightly than the connectors (the textbook calls it the tightest-binding operator, §1.4), as in its query disab! /p access! /s work-site work-place (employment /3 place). The three words therefore form one operand without parentheses. /s requires its two operands in the same sentence. explain! matches every word that begins with explain, which covers the verb's forms explain, explains, explained and explaining.

The truncation is chosen with the same care as employe! above. It does not reach the noun explanation, which begins explan, and the problem asks only for the verb. It does also match explainable and explainer, which is the price of a truncation. Writing professor! would add professors, and with it professorial and professorship.

Problem 2. Score and rank the five documents A to E for the query t1 OR t2 at $p = 1$, 2, 5 and $\infty$. At which value of $p$ does C overtake B?

Solution. The scores, from $\mathrm{sim}_{\mathrm{OR}} = \left((w_1^p + w_2^p)/2\right)^{1/p}$ and the maximum at $p = \infty$:

Document $w_1$ $w_2$ $p = 1$ $p = 2$ $p = 5$ $p = \infty$
A 1.0 1.0 1.000 1.000 1.000 1.000
B 0.8 0.6 0.700 0.707 0.727 0.800
C 1.0 0.0 0.500 0.707 0.871 1.000
D 0.5 0.5 0.500 0.500 0.500 0.500
E 0.3 0.2 0.250 0.255 0.268 0.300

One entry in full, B at $p = 2$: $\sqrt{(0.8^2 + 0.6^2)/2} = \sqrt{(0.64 + 0.36)/2} = \sqrt{0.5} \approx 0.707$. For C at any $p$ the score is $\left((1 + 0)/2\right)^{1/p} = 2^{-1/p}$, which is $\sqrt{0.5}$ at $p = 2$ as well.

So C overtakes B exactly at $p = 2$, where the two tie. For $p < 2$ the ranking is A, B, C, D, E, with C and D tied at $p = 1$. For $p > 2$ it is A, C, B, D, E, and at $p = \infty$ C ties with A. The movement is the mirror image of the AND table, where C sank as $p$ grew. OR rewards the single best term, and C's best term is a perfect match.

Problem 3. Under the weighted p-norm with $p = 2$, score document C, with $w_1 = 1$ and $w_2 = 0$, for t1 AND t2 when the query weights are (a) $a_1 = 2$, $a_2 = 1$ and (b) $a_1 = 1$, $a_2 = 2$. Compare with the unweighted score.

Solution. (a) 0.553, (b) 0.106, against 0.293 unweighted. The weighted AND score is

$$1 - \sqrt{\frac{a_1^2 (1 - w_1)^2 + a_2^2 (1 - w_2)^2}{a_1^2 + a_2^2}}.$$

For C the complements are $1 - w_1 = 0$ and $1 - w_2 = 1$, so only the second term of the numerator survives, and the score is $1 - \sqrt{a_2^2 / (a_1^2 + a_2^2)}$.

  • (a) $1 - \sqrt{1/5} \approx 1 - 0.447 = 0.553$.
  • (b) $1 - \sqrt{4/5} \approx 1 - 0.894 = 0.106$.
  • Unweighted, $a_1 = a_2$: $1 - \sqrt{1/2} \approx 0.293$, the value in the AND table.

C contains $t_1$ fully and lacks $t_2$. When the query says $t_1$ matters twice as much, the missing term costs less and C's score nearly doubles. When it says $t_2$ matters twice as much, the missing term is the important one and the score falls to about a third. A strict Boolean AND rejects C in all three cases. Stating that one concept matters more than another is something the Boolean model can do only by making it mandatory.

Problem 4. A collection has five documents, with the postings paper → {1, 2}, date → {2, 3} and book → {3, 4}. Which documents does a clause-based query return, and which optional clauses does each returned document match, for (a) filter date, optional paper, optional book; (b) the same with prohibited book instead of optional; (c) optional paper and optional book only?

Solution. (a) Documents 2 and 3. The filter clause decides the set: the documents of date. A filter clause counts as a required clause here. Lucene's documentation of BooleanQuery.Builder says that by default no optional clause has to match unless the query has no required clauses, and the source of Lucene 9.9.0 asks for an optional match only when a query has neither MUST nor FILTER clauses. So the optional clauses do not restrict the set, which is {2, 3}. Document 2 matches the optional paper and document 3 the optional book, so each has one optional match to score, and the filter adds nothing to either score.

(b) Document 2. The filter gives {2, 3}, and the prohibited clause removes the documents of book, {3, 4}, leaving {2}. This is date AND NOT book. Document 2 matches the optional paper.

(c) Documents 1, 2, 3 and 4. With no clause that must match, a document qualifies if it matches at least one optional clause, so the set is the union {1, 2} ∪ {3, 4}. This is paper OR book. Each document matches exactly one of the two clauses, and document 5 matches neither.

What we have learned

Boolean search survives where control matters: professional languages extend it with truncation, proximity, and fields, and ranked retrieval wins on average without making an exact, reportable search unnecessary. The p-norm grades a Boolean query, from plain averaging at $p = 1$ to strict minimum and maximum as $p$ grows. Modern engines keep Boolean logic as a filter and rank within it.

Exact matching gave way to graded matching, first in experimental models such as p-norms and then in the ranked models that dominate today. The next topic, the vector space model, develops the graded alternative from first principles: represent documents and queries as weighted vectors, and rank documents by their similarity to the query. It begins one step from Boolean matching. The first article, Zones and Weighted Zone Scoring, shows how a query term found in a document's title can count for more than one found in its body.

References

  • Apache Software Foundation (2023). Apache Lucene 9.9.0 API documentation: BooleanClause.Occur and BooleanQuery.Builder. https://lucene.apache.org/core/9_9_0/core/org/apache/lucene/search/BooleanClause.Occur.html record · 4 pages
  • Blair, D. C., and Maron, M. E. (1985). An evaluation of retrieval effectiveness for a full-text document-retrieval system. Communications of the ACM, 28(3), 289–299. record · 3 pages
  • Brin, S., and Page, L. (1998). The anatomy of a large-scale hypertextual Web search engine. Computer Networks and ISDN Systems, 30(1–7), 107–117. record · 4 pages
  • Kraft, D. H., and Buell, D. A. (1983). Fuzzy sets and generalized Boolean retrieval systems. International Journal of Man-Machine Studies, 19(1), 45–56. record
  • Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, sections 1.4, 3.2 and 21.1.1. Cambridge University Press. record · 102 pages
  • Salton, G., Fox, E. A., and Wu, H. (1983). Extended Boolean information retrieval. Communications of the ACM, 26(11), 1022–1036. record
  • Turtle, H. (1994). Natural language vs. Boolean query evaluation: A comparison of retrieval performance. In Proceedings of SIGIR 1994, 212–220. record

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