Why this matters
- VaultCommerce search must tolerate typos (
backpak), boost title matches over description, and filter by category without affecting score. - Using
matchon a keyword field ortermon analyzed text silently returns wrong results — the #1 Elasticsearch bug in production. - Relevance tuning (
boost,minimum_should_match, fuzziness) directly impacts conversion rate.
Cluster
Node 1Shard 0 primary
Node 2Shard 1 primary
Node 3Shard 0 replica
match: analyzed full-text
GET /vaultcommerce-products/_search
{
"query": {
"match": {
"title": {
"query": "trail pack waterproof",
"operator": "and"
}
}
}
}
The analyzer tokenizes input the same way it tokenized indexed text — lowercase, stemming optional, stop words removed per analyzer config.
bool: filter + must + should
GET /vaultcommerce-products/_search
{
"query": {
"bool": {
"must": [
{ "match": { "description": { "query": "hiking gear", "fuzziness": "AUTO" } } }
],
"filter": [
{ "term": { "category": "outdoor" } },
{ "range": { "price": { "lte": 100 } } },
{ "term": { "in_stock": true } }
],
"should": [
{ "match": { "title": { "query": "trail", "boost": 3 } } }
],
"minimum_should_match": 0
}
}
}
Bool clause roles
must— scored required clauses (contribute to relevance).filter— yes/no constraints cached without scoring (category, price range).should— optional boosts; useminimum_should_matchwhen they become required.must_not— exclusion filters (hide discontinued SKUs).
Filters run in filter context — faster and cacheable. VaultCommerce category sidebar uses filter clauses exclusively.
Term-level queries on keywords
GET /vaultcommerce-products/_search
{
"query": {
"term": { "sku": "SKU-8842" }
}
}
GET /vaultcommerce-products/_search
{
"query": {
"terms": { "tags": ["hiking", "camping"] }
}
}
Never term-query analyzed text — use match or a .raw keyword sub-field.
Multi-match and autocomplete
GET /vaultcommerce-products/_search
{
"query": {
"multi_match": {
"query": "summit tent",
"fields": ["title^3", "description", "tags^2"],
"type": "best_fields",
"fuzziness": "AUTO"
}
}
}
Prefix and match_phrase_prefix power typeahead — at scale, switch to edge n-gram analyzers at index time (covered in production ops).
Quick recall
Everything you need if you only revisit this box.
matchfor analyzed text;term/termsfor keyword fields.boolcombines must (scored), filter (not scored), should (boost), must_not.- Filters are cacheable — use for category, price, stock constraints.
multi_matchwith field boosts weights title over description.- Fuzziness
AUTOtolerates typos on customer search boxes. - VaultCommerce never term-queries analyzed description text.
Test yourself
Answer these before moving on — recall is what makes it stick.