Scrapeless Wiki

Vector Search vs. Keyword Search – Definition and Differences

Comparison P2 vector search vs keyword search

Compare vector and keyword search: how each ranks, where each fails, why hybrid retrieval wins, and how to choose for a given corpus.

The two approaches fail in opposite directions, which is why production systems rarely choose one. Understanding each failure mode is what makes combining them effective rather than merely fashionable.

Lexical retrieval ranks documents by term overlap with the query, weighted by how informative each term is.

  • Mechanism: an inverted index from terms to documents, scored by term frequency against document frequency.
  • Strength: exact matching, including rare identifiers.
  • Tuning: analysers, stemming, synonyms, and field weights.

Semantic retrieval embeds query and documents into a shared space and ranks by distance.

  • Mechanism: an embedding model plus an approximate nearest-neighbour index.
  • Strength: paraphrase and conceptual similarity.
  • Tuning: model choice, chunking, and re-ranking.

3. Key Differences

Dimension Keyword Vector
Matches Terms and their variants Meaning
Rare identifiers Excellent Poor
Paraphrase Poor without synonyms Excellent
Negation Literal and reliable Weak β€” opposites sit close together
New vocabulary Works immediately Needs the term in training data
Explainability Matched terms are visible Distances are opaque
Index cost Low Higher: embedding plus vector index
Update cost Reindex the document Re-embed the document

4. Where Each Fails

Keyword search fails when the user's vocabulary differs from the author's: a symptom described in plain language against documentation written in product terms.

Vector search fails on exact tokens β€” part numbers, error codes, version strings β€” and on negation, where "supports X" and "does not support X" are neighbours.

5. Why Hybrid Wins

Hybrid retrieval runs both and fuses the rankings, usually by combining ranks rather than raw scores, since the two scales are not comparable.

The benefit is clearest on mixed queries β€” natural language plus an identifier β€” which are extremely common in technical and commercial search. Vectors carry the prose; the lexical index anchors the token.

6. Re-Ranking Sits Above Both

Whichever retrievers are used, a re-ranking model that scores query and passage together is usually the cheapest large quality improvement. Retrieve broadly, re-rank precisely, and keep only the top few.

7. Choosing for a Corpus

  • Identifier-heavy (catalogues, code, logs) β€” keyword first, vectors added for descriptive queries.
  • Prose-heavy (documentation, articles, tickets) β€” vectors first, keyword added for exact tokens.
  • Mixed β€” hybrid from the start; it is the common case.
  • Small corpus β€” an exact vector scan is simple and adequate; no ANN index is required.

8. Summary

Keyword search matches terms, vector search matches meaning, and each is weakest exactly where the other is strongest.

Hybrid retrieval with re-ranking is the default that survives contact with real queries β€” not because combining is sophisticated, but because real queries contain both prose and identifiers.