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.
| ID | Catalogue entry |
|---|---|
| The Cat and Dog in the Forest. A cat and a dog begin a woodland adventure. | |
| Cats of the Woodland. Wild cats begin an adventure beneath ancient trees. | |
| The Forest Hound. A loyal dog follows a woodland trail through ancient trees. | |
| Feline Detective. A clever cat solves mysteries with a canine companion. | |
| Random Forest for Pet Detection. A random forest model classifies cats and dogs in photographs. | |
| Forests of Search Trees. Algorithms explore a forest of binary trees and graph paths. | |
| Dog Dog Dog! A dog chases a ball, finds a bone, and wakes the neighbors. | |
| Forest Forest Forest! A forest guide names trees, flowers, rivers, birds, and hidden ruins. | |
| Cat Dog Forest. | |
| Cat Dog Forest. A cat meets a dog in a forest beside rivers, mountains, castles, villages, bridges, and caves. | |
| Woodland Companions. A kitten and a puppy share a moonlit adventure among old trees. | |
| 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:
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 . For cat OR dog, the predicate evaluates to true if at least one condition is met, producing the larger result set .
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:
For example, 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 , the system checks whether every atomic predicate is true or false and then evaluates the complete expression. For cat AND dog, produces , whereas produces .
A second method starts from all documents that satisfy each atomic predicate. Let denote the set of documents containing term . For the running collection:
The documents satisfying cat AND dog must belong to both sets. The documents satisfying cat OR dog may belong to either set:
More generally, each atomic predicate defines a set of matching documents:
The DNF structure translates directly into intersections for AND and unions for OR:
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, contains “dog” and “trees”, while 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 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, , , , and are equivalent Boolean matches. The model ignores that and repeat both query terms, that consists only of the three topical terms “cat”, “dog”, and “forest”, and that much of 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 , , , and the same Boolean status. Yet their evidence differs: and contain both terms twice, while and contain them once. Documents such as and 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 in document , define
where is a fixed normalization value shared by the collection. A positive term predicate uses this weight directly; a negative predicate reverses it:
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 and soft OR as distance from .
Other soft Boolean operators are possible. They differ in how strongly one high or low atomic score influences the combined result.
Alternative soft Boolean operators (optional reading)
The fuzzy set model uses the weakest score for AND and the strongest score for OR:
This preserves the strict interpretation of AND and OR most directly, but ignores all scores except the extreme one.
The fuzzy algebraic model combines two operands using a product for AND and a probabilistic sum for OR:
A further family interpolates between the minimum and maximum. For AND, a parameter closer to the minimum emphasizes the weakest condition; for OR, a parameter closer to the maximum emphasizes the strongest condition. These alternatives illustrate that softening Boolean logic requires a modelling choice: Boolean algebra alone does not determine the graded operator.
Evaluating the Running Example¶
Consider cat AND dog with . In the 12-document collection, and , so
For this example, choose , 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.
| Document | p-norm AND score | ||
|---|---|---|---|
| 0.632 | 0.500 | 0.561 | |
| 0.632 | 0.500 | 0.561 | |
| 0.000 | 1.000 | 0.293 | |
| 0.316 | 0.250 | 0.282 | |
| 0.316 | 0.250 | 0.282 | |
| 0.316 | 0.000 | 0.143 | |
| 0.000 | 0.250 | 0.116 |
The model now distinguishes repeated evidence: and rank above and . It also assigns positive scores to the partial matches , , and . 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. contains “dog” four times but no “cat”, yet it narrowly outranks , which contains both requested terms. A different value of , 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.