Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Boolean Retrieval

The previous section transformed raw text into tokens and term-frequency vectors. A retrieval model takes these representations and decides which documents match a query and, for ranked models, how strongly each document matches. We use the following small fictional library catalogue as a running example. Its wording is deliberately controlled so that the effects of preprocessing, term weighting, document length, and lexical ambiguity remain visible.

IDCatalogue entry
D1D_1The Cat and Dog in the Forest. A cat and a dog begin a woodland adventure.
D2D_2Cats of the Woodland. Wild cats begin an adventure beneath ancient trees.
D3D_3The Forest Hound. A loyal dog follows a woodland trail through ancient trees.
D4D_4Feline Detective. A clever cat solves mysteries with a canine companion.
D5D_5Random Forest for Pet Detection. A random forest model classifies cats and dogs in photographs.
D6D_6Forests of Search Trees. Algorithms explore a forest of binary trees and graph paths.
D7D_7Dog Dog Dog! A dog chases a ball, finds a bone, and wakes the neighbors.
D8D_8Forest Forest Forest! A forest guide names trees, flowers, rivers, birds, and hidden ruins.
D9D_9Cat Dog Forest.
D10D_{10}Cat Dog Forest. A cat meets a dog in a forest beside rivers, mountains, castles, villages, bridges, and caves.
D11D_{11}Woodland Companions. A kitten and a puppy share a moonlit adventure among old trees.
D12D_{12}The Pet Bakery. A cat, a dog, and a baker make cakes, bread, biscuits, pies, and coffee.

Following From Text to Searchable Vectors, we must define the preprocessing pipeline before applying a retrieval model. For this example, we lowercase the text, split it at punctuation and whitespace, and remove common stop words. We deliberately apply neither stemming nor lemmatization, and we do not expand synonyms. For example:

D1↦[cat,dog,forest,cat,dog,begin,woodland,adventure]D_1 \mapsto [\text{cat},\text{dog},\text{forest},\text{cat},\text{dog},\text{begin},\text{woodland},\text{adventure}]

D2↦[cats,woodland,wild,cats,begin,adventure,beneath,ancient,trees]D_2 \mapsto [\text{cats},\text{woodland},\text{wild},\text{cats},\text{begin},\text{adventure},\text{beneath},\text{ancient},\text{trees}]

These choices expose an important property of lexical matching: terms match by identity, not by visual or semantic similarity. During vocabulary construction, each distinct token receives its own identifier. For example, the vocabulary might map “cat” to token ID 70 and “cats” to token ID 83. A retrieval model therefore treats them as two unrelated dimensions, even though a reader immediately recognizes their relationship. For the same reason, “cat” does not match “feline” or “kitten”, and “dog” does not match “hound”, “canine”, or “puppy”. The reverse problem occurs with “forest”: the same token ID represents both a natural environment and the technical concept in “random forest”, although the meanings differ.

Standard Boolean Model

Consider the query cat AND dog. For each document, we test two conditions: the token “cat” is present, and the token “dog” is present. The complete predicate evaluates to true only if both conditions are met. The result set is therefore {D1,D9,D10,D12}\{D_1,D_9,D_{10},D_{12}\}. For cat OR dog, the predicate evaluates to true if at least one condition is met, producing the larger result set {D1,D3,D4,D7,D9,D10,D12}\{D_1,D_3,D_4,D_7,D_9,D_{10},D_{12}\}.

This is the central idea of the Standard Boolean Model: a query is a predicate that maps each document to either true or false. Documents for which the predicate is true enter the result set; all others are excluded. The model filters rather than ranks, so every returned document has the same status regardless of how often or where the terms occur. This makes Boolean retrieval simple to understand, easy to calculate, and straightforward to explain.

Query Language

The query grammar defines two atomic predicates: a term is present, or a term is absent. It then defines two composition rules: AND and OR combine existing predicates into more complex expressions. Formally:

Q=t(term t must be present)Q = t \quad \text{(term } t \text{ must be present)}
Q=¬t(term t must be absent)Q = ¬ t \quad \text{(term } t \text{ must be absent)}
Q=Q1∨Q2(at least one sub-query must be true)Q = Q_1 ∨ Q_2 \quad \text{(at least one sub-query must be true)}
Q=Q1∧Q2(both sub-queries must be true)Q = Q_1 ∧ Q_2 \quad \text{(both sub-queries must be true)}

For example, (cat∧dog)∨hound(\text{cat} ∧ \text{dog}) ∨ \text{hound} returns a document if it contains both “cat” and “dog”, or if it contains “hound”. Boolean algebra allows any such expression to be rewritten in disjunctive normal form (DNF):

Evaluating a Query

The direct evaluation method follows the initial intuition. For each document DiD_i, the system checks whether every atomic predicate τl,k\tau_{l,k} is true or false and then evaluates the complete expression. For cat AND dog, D1D_1 produces true∧true=true\text{true} ∧ \text{true} = \text{true}, whereas D4D_4 produces true∧false=false\text{true} ∧ \text{false} = \text{false}.

A second method starts from all documents that satisfy each atomic predicate. Let St\mathbb{S}_t denote the set of documents containing term tt. For the running collection:

Scat={D1,D4,D9,D10,D12}\mathbb{S}_{\text{cat}} = \{D_1,D_4,D_9,D_{10},D_{12}\}

Sdog={D1,D3,D7,D9,D10,D12}\mathbb{S}_{\text{dog}} = \{D_1,D_3,D_7,D_9,D_{10},D_{12}\}

The documents satisfying cat AND dog must belong to both sets. The documents satisfying cat OR dog may belong to either set:

Scat∩Sdog={D1,D9,D10,D12}\mathbb{S}_{\text{cat}} ∩ \mathbb{S}_{\text{dog}} = \{D_1,D_9,D_{10},D_{12}\}

Scat∪Sdog={D1,D3,D4,D7,D9,D10,D12}\mathbb{S}_{\text{cat}} \cup \mathbb{S}_{\text{dog}} = \{D_1,D_3,D_4,D_7,D_9,D_{10},D_{12}\}

More generally, each atomic predicate defines a set of matching documents:

Sl,k={{Di∣tf(Di,tj(l,k))≥1}if τl,k=tj(l,k){Di∣tf(Di,tj(l,k))=0}if τl,k=¬tj(l,k).\mathbb{S}_{l,k} = \begin{cases} \{D_i \mid \text{tf}(D_i, t_{j(l,k)}) \geq 1\} & \text{if } \tau_{l,k} = t_{j(l,k)} \\ \{D_i \mid \text{tf}(D_i, t_{j(l,k)}) = 0\} & \text{if } \tau_{l,k} = ¬ t_{j(l,k)}. \end{cases}

The DNF structure translates directly into intersections for AND and unions for OR:

Q=⋃l=1L⋂k=1KlSl,k\mathbb{Q} = ⋃_{l=1}^{L} ⋂_{k=1}^{K_l} \mathbb{S}_{l,k}

An inverted file stores these term-document sets so that the system can combine them without scanning every document. Chapter 4 develops this index structure and its efficient query-processing algorithms.

Limitations of Boolean Retrieval

Suppose the information need is a story involving a cat, a dog, and trees. The strict query cat AND dog AND trees returns no documents. Several entries are plausible partial matches, but none contains all three exact tokens. For example, D3D_3 contains “dog” and “trees”, while D1D_1 contains “cat”, “dog”, “forest”, and “woodland”. Boolean evaluation excludes both because a missing term makes the complete AND predicate false.

Relaxing the query to cat OR dog OR trees creates the opposite problem: it returns 11 of the 12 documents. The result includes technical entries such as D6D_6 because it contains “trees”, even though these are binary search trees rather than trees in an animal story. Small changes to a Boolean expression can therefore produce abrupt changes in result-set size, from no results to almost the entire collection.

The model also provides no basis for ordering the matches. For cat AND dog, D1D_1, D9D_9, D10D_{10}, and D12D_{12} are equivalent Boolean matches. The model ignores that D1D_1 and D10D_{10} repeat both query terms, that D9D_9 consists only of the three topical terms “cat”, “dog”, and “forest”, and that much of D12D_{12} concerns baking. Term frequency, term importance, document length, and partial evidence do not affect the result.

These limitations establish the questions for the models that follow. The Extended Boolean Model introduces graded matching and ranking while retaining Boolean query structure. Probabilistic and vector-space models provide alternative foundations for term weighting and ranking, while BM25 later combines probabilistic term importance with term-frequency saturation and document-length normalization. We will return to the same collection to see which limitation each model addresses.

Advantages: The model has simple and precise query semantics. Its decisions are easy to calculate and explain, and set operations support fast evaluation over large collections. Boolean predicates also combine naturally with structured metadata filters such as language = English.

Disadvantages: Users must express their information need as a Boolean expression and may obtain either too few or too many results. The model neither ranks matches nor represents partial matches. All predicates have equal influence, regardless of term frequency or discriminating power. These properties make the model better suited to exact filtering than to ranking documents by relevance.

Boolean retrieval nevertheless remains an important component of modern text and web search systems. A fast first stage often combines query terms with OR to retrieve a broad candidate set. A second stage then assigns relevance scores and ranks these candidates, allowing the user to inspect the strongest matches first. The next model takes an initial step in this direction by replacing Boolean decisions with graded scores.

Extended Boolean Model

The query cat AND dog gave D1D_1, D9D_9, D10D_{10}, and D12D_{12} the same Boolean status. Yet their evidence differs: D1D_1 and D10D_{10} contain both terms twice, while D9D_9 and D12D_{12} contain them once. Documents such as D3D_3 and D4D_4 contain only one query term and are excluded completely. The Extended Boolean Model replaces this hard boundary with a graded score. It can rank exact matches and retain partial matches with lower scores.

What Remains Boolean, and What Changes?

The query language remains the same. Users still express requirements with term predicates, AND, OR, and NOT, and the query retains its tree structure. What changes is the evaluation of that tree. An atomic predicate no longer produces only true or false. It produces a score between 0 and 1 that reflects the strength of the term evidence. Soft versions of AND and OR then combine these scores.

This extension directly addresses two limitations of the Standard Boolean Model. Term frequency and inverse document frequency can distinguish stronger from weaker evidence, while graded operators allow a document to receive a positive score even if it does not satisfy every predicate. The output is therefore a ranked list rather than an unordered set.

Formalizing Graded Evidence

Each document is represented by normalized TF-IDF weights. For term tjt_j in document DiD_i, define

di,j=min⁡(1,  tf(Di,tj) idf(tj)α),0≤di,j≤1,d_{i,j} = \min\left(1,\; \frac{\text{tf}(D_i,t_j)\,\text{idf}(t_j)}{\alpha}\right), \qquad 0 \leq d_{i,j} \leq 1,

where α\alpha is a fixed normalization value shared by the collection. A positive term predicate uses this weight directly; a negative predicate reverses it:

sim(τ,Di)={di,jif τ=tj,1−di,jif τ=¬tj.\text{sim}(\tau,D_i) = \begin{cases} d_{i,j} & \text{if } \tau=t_j, \\ 1-d_{i,j} & \text{if } \tau=¬ t_j. \end{cases}

The remaining question is how to combine the atomic scores. The p-norm model, introduced by Salton, Fox, and Wu; see Extended Boolean Information Retrieval in the Further Reading section of the chapter summary, interprets soft AND as closeness to the ideal point (1,…,1)(1,\ldots,1) and soft OR as distance from (0,…,0)(0,\ldots,0).

Other soft Boolean operators are possible. They differ in how strongly one high or low atomic score influences the combined result.

Evaluating the Running Example

Consider cat AND dog with p=2p=2. In the 12-document collection, df(cat)=5\text{df}(\text{cat})=5 and df(dog)=6\text{df}(\text{dog})=6, so

idf(cat)=ln⁡(12/5)≈0.875,idf(dog)=ln⁡(12/6)≈0.693.\text{idf}(\text{cat})=\ln(12/5)\approx0.875, \qquad \text{idf}(\text{dog})=\ln(12/6)\approx0.693.

For this example, choose α=4ln⁡2≈2.773\alpha=4\ln 2\approx2.773, the largest TF-IDF weight among these query terms. We compute the two atomic scores for each candidate and combine them with the p-norm AND formula.

Documentdi,catd_{i,\text{cat}}di,dogd_{i,\text{dog}}p-norm AND score
D1D_10.6320.5000.561
D10D_{10}0.6320.5000.561
D7D_70.0001.0000.293
D9D_90.3160.2500.282
D12D_{12}0.3160.2500.282
D4D_40.3160.0000.143
D3D_30.0000.2500.116

The model now distinguishes repeated evidence: D1D_1 and D10D_{10} rank above D9D_9 and D12D_{12}. It also assigns positive scores to the partial matches D3D_3, D4D_4, and D7D_7. Evaluation can still use an inverted file: the union of the query-term postings supplies candidates, after which the system computes and sorts their scores.

Limitations of the Extended Boolean Model

The ranking also exposes the heuristic nature of the method. D7D_7 contains “dog” four times but no “cat”, yet it narrowly outranks D9D_9, which contains both requested terms. A different value of pp, another normalization constant, or another soft operator can change this order. The query grammar states what AND and OR mean for true and false values, but it does not uniquely determine how graded evidence should be combined.

The model also inherits the lexical limitations of its representation. It still does not connect “cat” with “cats” or “feline”, and it cannot distinguish the meanings of “forest”. Finally, users must still translate an information need into an explicit Boolean expression. Graded evaluation softens the consequences of that expression but does not remove the burden of formulating it.

Advantages: The model retains the familiar Boolean query structure while adding partial matches and ranked output. TF-IDF weights distinguish terms by occurrence and collection frequency, and inverted files still support efficient candidate retrieval.

Disadvantages: Scores depend on heuristic choices for normalization, operators, and parameters, which can produce counter-intuitive rankings. The model retains lexical matching and explicit Boolean query formulation.

The classical p-norm model is rarely used as the primary ranker in modern search engines. Its central idea remains relevant, however: contemporary systems often combine strict Boolean filters with optional scoring clauses. This preserves explicit query constraints while allowing partial matches to receive different relevance scores. The Vector Space Model in the next section takes the next conceptual step: it replaces explicit Boolean expressions with free-text queries and ranks documents directly from their weighted term vectors.