GLOSSARY

Field Query

A field query searches a specific field like title:"air max" or brand:Nike. In stores, it powers advanced search and precise matches for titles, SKUs, and attributes.

What is a Field Query?

A field query (fielded search) targets one or more specific fields in the index using prefixes or a query DSL, e.g., title:, brand:, sku:, category:, price:. It gives precise control compared to a general, all-fields query.

How It Works (quick)

  • Mapping: Define which fields are searchable and with which analyzers (title vs description vs keyword).
  • Syntax: Prefix (title:"air max"), filters (price:[50 TO 100]), and exact fields (sku:"AB-1234").
  • Boosting: Weight fields differently (title > attributes > description).
  • Fallback: Multi-match across common fields when the user doesn’t specify one.

Why It Matters in E-commerce

  • Precision: Exact title/brand searches and SKU/MPN lookups.
  • Power-user tooling: Merchandisers and support agents resolve issues quickly.
  • Safer parsing: Limits ambiguity vs free-text queries.

Best Practices

  • Whitelist fields: Only expose safe, meaningful fields; hide internals.
  • Per-field analyzers: Exact/keyword for SKUs; language analyzers for titles; numeric/range for price.
  • Synonyms by field: Brand synonyms differ from description synonyms; manage separately.
  • Sanitize input: Prevent query injection; escape reserved characters.
  • UX: Provide an Advanced Search helper or query builder; show examples.
  • Logging: Store parsed fields for debugging and analytics.

Challenges

  • User confusion over syntax; long, brittle URLs; inconsistent analyzers across locales.

Examples

  • title:"air max 270" AND brand:Nike AND price:[80 TO 150]
  • sku:AB-1234 → exact keyword field.
  • category:Accessories AND color:Red

Summary

Field queries offer surgical control over where and how search matches happen. Expose the right fields with the right analyzers, sanitize inputs, and provide a good UI for non-experts.

FAQ

Field query vs filter?

Field queries target searchable fields and can affect scoring; filters constrain results without affecting text scores.

Should customers see this?

Offer a friendly builder for shoppers; keep raw syntax for admins and power users.

How does this interact with boosting?

Use BM25F/field boosts so title: matches carry more weight than description:.