Multi-field product search often produces inconsistent results when the same query is sent to every field and the scores are blended without considering which field matched best. A shopper searching for running shoes should usually see a product with those words in its name above a product that only mentions them in a long description.
Elasticsearch’s dis_max query is useful for this ranking problem. It selects the highest score from several subqueries and can optionally add a controlled portion of the scores from the other matching queries. This makes the strongest field match the primary ranking signal instead of allowing many weaker matches to overwhelm it.
Why Disjunction Max Helps Product Search
Consider a WooCommerce product indexed with separate fields for its name, SKU, short description, and category names. A search for blue trail jacket may match all four fields, but those matches do not have equal commercial value:
- A match in the product name is usually highly relevant.
- A match in the SKU may identify an exact product but should not dominate a normal phrase search unless it is exact.
- A match in the short description provides useful supporting evidence.
- A category match is helpful, but is often less specific than a product-name match.
A conventional boolean query with several should clauses can reward products that match many low-value fields more than products with one excellent name match. dis_max changes that behavior by using the best matching clause as the base score.
Basic Disjunction Max Query
The following query gives the product name the largest boost, while still searching supporting fields:
{
"query": {
"dis_max": {
"queries": [
{
"match": {
"name": {
"query": "blue trail jacket",
"operator": "and",
"boost": 4
}
}
},
{
"match": {
"short_description": {
"query": "blue trail jacket",
"operator": "and",
"boost": 2
}
}
},
{
"match": {
"category_names": {
"query": "blue trail jacket",
"boost": 1.2
}
}
}
],
"tie_breaker": 0.15
}
}
}
With this structure, the highest scoring clause supplies the primary score. The tie_breaker adds 15 percent of the scores from the other matching clauses. A product that matches both its name and category can therefore receive a modest benefit, but several weak matches will not completely overpower a strong name match.
Choosing the Tie Breaker
The tie_breaker is a value between 0 and 1. A value of 0 uses only the best matching clause. Small values such as 0.1 or 0.2 are generally a good starting point for catalog search because they reward corroborating matches without turning every field into an equal vote.
Higher values make secondary matches more influential. This may be appropriate when a catalog has reliable synonyms or structured field content, but it can also cause verbose descriptions to dominate the results. Agencies should test the setting against real search logs rather than choosing it solely from theoretical scoring behavior.
Using Multi-Match Best Fields
For analyzed text fields, multi_match with type: best_fields is a concise alternative. Elasticsearch implements this mode using a disjunction-max style query, so the best matching field is favored:
{
"query": {
"multi_match": {
"query": "wireless charging stand",
"type": "best_fields",
"fields": [
"name^4",
"short_description^2",
"description",
"category_names^1.2"
],
"operator": "and",
"tie_breaker": 0.15
}
}
}
Field boosts are relative rather than absolute business rules. A boost of 4 does not mean the name is exactly four times as relevant in every case; the analyzer, term frequency, field norms, and query structure all affect the final score. Verify the result with Elasticsearch’s _explain API or the profile option during development.
Handling SKUs Separately
SKUs usually need a different strategy from natural-language fields. If a SKU is mapped as a keyword, use an exact term query and give it a controlled boost. Keep it as a separate clause so an exact product-code search can be highly effective without making partial SKU text distort ordinary searches.
{
"query": {
"dis_max": {
"queries": [
{
"term": {
"sku": {
"value": "abc-123",
"boost": 8
}
}
},
{
"multi_match": {
"query": "abc-123",
"type": "best_fields",
"fields": [
"name^4",
"short_description^2",
"category_names"
],
"tie_breaker": 0.1
}
}
],
"tie_breaker": 0.05
}
}
}
Normalize SKU values consistently at index and query time. Decide whether case, spaces, and punctuation should be ignored, and use a dedicated normalized keyword field when necessary. Do not rely on an analyzed product-name field to provide reliable SKU matching.
Phrase Matching for Product Names
When word order matters, add a phrase-oriented clause for the product name. A product named wireless charging stand should generally rank above one containing the same words scattered across a long description.
{
"query": {
"dis_max": {
"queries": [
{
"match_phrase": {
"name": {
"query": "wireless charging stand",
"boost": 6
}
}
},
{
"multi_match": {
"query": "wireless charging stand",
"type": "best_fields",
"fields": [
"name^4",
"short_description^2",
"description"
],
"operator": "and",
"tie_breaker": 0.15
}
}
],
"tie_breaker": 0.1
}
}
}
Use phrase matching as a ranking signal, not as the only query, unless the storefront specifically requires exact wording. Shoppers often omit words, change their order, or use a synonym that should still retrieve the product.
Implementation Checks for WooCommerce Agencies
- Map product names, short descriptions, and category names as analyzed text fields with an analyzer appropriate for the store’s language.
- Keep exact identifiers such as SKU, GTIN, and manufacturer part number in keyword fields.
- Use field boosts and tie-breaker values as tunable configuration rather than hard-coding them throughout the integration.
- Test discontinued products, out-of-stock products, variations, and products with empty descriptions.
- Apply availability, catalog visibility, language, and permission rules in filters or post-filter logic so relevance scoring is not responsible for hiding invalid products.
- Evaluate rankings with real queries, click data, zero-result searches, and known product lookups.
For most WooCommerce catalogs, a practical starting point is multi_match with best_fields, a modest tie_breaker, a stronger product-name boost, and a separate exact SKU clause. This keeps the query maintainable while preserving the ranking behavior of an explicit dis_max design when more control is needed.