liveBook · Manning

Lexical search

As explained in The Art of AI Product Development

Lexical search retrieves and ranks documents by matching words or phrases in their textual forms.

Lexical search retrieves documents by matching exact words or phrases. It is especially valuable when a query contains technical terms, product-taxonomy phrases, API endpoints, or ambiguous words whose precise form matters. section 7.2.4 section 7.2.2

A lexical system can rank matches with Best Matching 25 (BM25), which considers how often a term appears and how distinctive it is across the document collection. This prioritizes useful exact hits instead of returning every document containing the term. section 7.2.4

Use lexical search when:

  • A phrase such as “augmented workflow” must refer to one defined feature rather than merely related concepts. section 7.2.4
  • Users need exact API endpoints or other company-specific terminology. section 7.2.4
  • A word is ambiguous, such as “business” in an airline query, and broad semantic similarity produces irrelevant results. section 7.2.4

Precision plus context

A search for “augmented workflow” may retrieve semantically related material, but lexical matching ensures documents containing that exact taxonomy phrase appear. Combining both approaches preserves semantic context while improving precision. section 7.2.4

Lexical search does not replace semantic search: exact matching can miss documents that use synonyms or related wording. A combined system uses lexical precision alongside semantic recall, with metadata filters as another retrieval optimization. section 7.2.2 section 7.4

How The Art of AI Product Development covers it

How deep it goes
Explains exact matching, BM25 ranking, and combination with semantic search, but stops short of implementation details.
Examples
Uses augmented workflow, API endpoints, and airline business-class queries to demonstrate exact matching and ambiguity.
What it assumes
Assumes familiarity with search retrieval and contrasts exact keyword matching with semantic similarity.
What you can do after
Apply it via BM25 ranking and combine it with semantic search to improve retrieval precision.
How it connects
Connects lexical search with semantic search, BM25, metadata filters, and retrieval-augmented generation.

Also explained in

Compare how 8 books explain lexical search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of AI Product Development. The section links point to the parts of the book it draws on.