Phrase Matching

Phrase matching looks for words that appear together in order, like “air max 270.” In stores, it boosts precision for model names and common two- or three-word units.

What is Phrase Matching?

Phrase matching requires adjacent, ordered tokens to appear together (or within a small window). It’s implemented with inverted indexes that store positions, phrase queries with slop, and/or bigram/phrase fields.

How It Works (quick)

  • Index with positions: Store token positions per field for phrase/proximity queries.
  • Query types: Exact phrase ("air max 270"), proximity with slop (allow 1–2 gaps), and bigram/trigram fields.
  • Scoring: Combine with BM25/TF-IDF, field boosts (title > attributes > description).
  • Normalization: Handle hyphens/diacritics; keep brand casing in exact fields.
  • Blending: Try phrase matches first; fall back to unigrams/fuzzy when needed.

Why It Matters in E-commerce

  • Model integrity: Lifts brand+model strings and prevents split-token noise.
  • Natural queries: Captures common units (“trail running”, “phone case”).
  • CTR gains: Better snippets/highlights increase click confidence.

Best Practices

  • Add bigram fields for titles; use phrase queries with small slop.
  • Protect SKU/MPN with exact keyword fields (no fuzz).
  • Normalize variants (hyphen/space) into the same match family.
  • Cap phrase boosts so poor items don’t outrank clearly better ones.
  • Log missed phrases and expand analyzers where justified.

Challenges

  • Language variation (“tee-shirt” vs “T-shirt”), tokenization across locales, and over-boosting exact but irrelevant phrases.

Examples

  • "air max 270" in title outranks documents where tokens are scattered.
  • "gore tex jacket" matches GORE-TEX jacket via normalized hyphenation.

Summary

Phrase matching encodes common word units and model names, improving precision and CTR. Use positions, small-slop phrase queries, and bigram fields—with careful normalization and sensible boosts.

FAQ

Phrase vs exact match?

Phrase enforces order & adjacency; exact match may simply match tokens/fields exactly.

What is slop?

A tolerance for small gaps or reorders in phrase queries.

Do I still need bigrams if I store positions?

Often yes—bigrams are fast and help ranking even when phrase queries exist.

Related terms

See these concepts in action: semantic, typo-tolerant search for Shopify stores — implemented by Rapid Search