Table of contents :

Boosting Your Most Important Product Fields

100-days-of-elasticsearch-woocommerce-023

Table of contents :

Not every product field deserves equal influence in search results. For most WooCommerce catalogs, a match in the product name is a stronger signal than a match in a long description, while an exact SKU match may be more important than either. Elasticsearch lets you express those priorities with field boosts.

What a field boost does

A field boost changes how strongly a match contributes to a document’s relevance score. In a multi_match query, a boost is added to the field name with the ^ notation:

{
  "query": {
    "multi_match": {
      "query": "waterproof hiking boot",
      "fields": [
        "name^5",
        "sku^8",
        "short_description^2",
        "description",
        "categories.name^3",
        "attributes.value^2"
      ],
      "type": "best_fields"
    }
  }
}

In this example, a match in sku receives the highest preference, followed by the product name. The description remains searchable, but it has less influence when several products match the same query.

Choose boosts according to customer intent

Boost values are relative weights, not percentages. A field with ^4 is not guaranteed to rank twice as high as a field with ^2; the final score also depends on term frequency, analysis, query type, and the other clauses in the search request.

A practical starting point for a typical WooCommerce product index is:

  • Product name: ^5 or ^6. This is usually the clearest description of what the customer wants.
  • SKU: ^8 or ^10 when customers commonly search by catalog number. Consider exact matching separately.
  • Product and variation attributes: ^2 or ^3. Color, size, material, and compatibility terms are often important filters and search terms.
  • Categories and tags: ^2 or ^3. These provide useful merchandising context without overwhelming the product name.
  • Short description: ^2. It generally contains concise selling points and important product terminology.
  • Long description: ^1. It is useful for recall, but broad descriptive text can produce noisy matches.
  • Search keywords or synonyms: a moderate boost, such as ^2, if these fields are curated and not automatically populated with unrelated terms.

Separate exact identifiers from general text

SKUs, model numbers, UPCs, and manufacturer part numbers should not rely only on analyzed text fields. Index an exact-value subfield, commonly mapped as keyword, and give exact matches a dedicated query clause.

{
  "query": {
    "bool": {
      "should": [
        {
          "term": {
            "sku.keyword": {
              "value": "WB-2048",
              "boost": 20
            }
          }
        },
        {
          "multi_match": {
            "query": "WB-2048",
            "fields": [
              "name^5",
              "sku^8",
              "short_description^2",
              "description"
            ]
          }
        }
      ],
      "minimum_should_match": 1
    }
  }
}

The exact clause can move the requested product to the top when the complete identifier is entered, while the broader clause still supports partial or natural-language searches. The exact field must be populated consistently; otherwise the clause will not match.

Use nested fields correctly

Product attributes are often represented as arrays of objects containing a name and one or more values. If the mapping uses the nested type, query those fields with a nested query. A regular dotted field query can associate the value from one attribute with the name of another attribute.

{
  "query": {
    "nested": {
      "path": "attributes",
      "query": {
        "multi_match": {
          "query": "stainless steel",
          "fields": [
            "attributes.name^2",
            "attributes.value^3"
          ]
        }
      }
    }
  }
}

The exact field names depend on the document structure created by the WooCommerce integration. Inspect the index mapping and a representative product document before adding nested queries or boosts to production.

Combine field boosts with business rules carefully

Field relevance and merchandising rules solve different problems. A field boost answers, “Which textual match is more useful?” A business rule answers, “Should this product be promoted, demoted, or excluded?” Keep those concerns distinguishable where possible.

For example, a search query can use boosted text fields and then apply a modest popularity or stock adjustment:

{
  "query": {
    "function_score": {
      "query": {
        "multi_match": {
          "query": "running jacket",
          "fields": [
            "name^6",
            "categories.name^3",
            "attributes.value^2",
            "short_description^2",
            "description"
          ]
        }
      },
      "field_value_factor": {
        "field": "popularity",
        "factor": 0.1,
        "modifier": "log1p",
        "missing": 0
      },
      "boost_mode": "sum"
    }
  }
}

Do not use a popularity factor to compensate for weak field configuration. A highly popular product should not outrank a clearly better textual match solely because its sales count is larger. Also decide explicitly how out-of-stock products are handled; filtering them out is different from merely reducing their score.

Prefer controlled boosts over excessive boosts

Very large boosts can hide indexing and analysis problems. If a product name is missing a synonym, contains inconsistent punctuation, or is analyzed differently from the customer’s query, increasing its boost will not fix the underlying mismatch.

Before changing weights, verify that:

  • The field is present in the indexed document after product updates and variation synchronization.
  • The analyzer produces expected tokens for common product terms.
  • Exact identifier fields use the intended keyword mapping.
  • Category, tag, and attribute values are not duplicated into several fields without a clear reason.
  • Unavailable or hidden products are filtered according to the store’s catalog rules.

Test boosts with representative WooCommerce searches

Use a test set based on real searches rather than a handful of invented examples. Include product names, partial SKUs, model numbers, category terms, attribute combinations, misspellings, and queries that should return no results.

For each query, record whether the expected products appear on the first page and whether the order is sensible. Compare a baseline query with one change at a time, such as increasing name^4 to name^6. Elasticsearch’s _explain API can show why a particular document received its score, although it should generally be used for debugging selected documents rather than every production request.

GET products/_explain/PRODUCT_ID
{
  "query": {
    "multi_match": {
      "query": "waterproof hiking boot",
      "fields": [
        "name^6",
        "categories.name^3",
        "attributes.value^2",
        "description"
      ]
    }
  }
}

After changing boosts, reindex if the integration stores derived search fields or changes mappings. A query-only boost change normally does not require reindexing, but changing analyzers, field types, or indexed content does.

Account for variations and WooCommerce-specific data

Variation-heavy catalogs need a deliberate document strategy. If variations are indexed as separate documents, boost variation attributes and variation SKUs directly. If variations are embedded in the parent product, ensure their searchable values are exposed in fields that the query actually targets. Otherwise, a customer searching for a specific size, color, or compatibility code may see the parent product ranked for a weaker match.

Do not assume that the WordPress or WooCommerce field name is the Elasticsearch field name. A plugin or custom indexing layer may rename fields, flatten taxonomies, or combine product and variation data. Confirm the generated mapping and document shape, then make the boost configuration match the indexed structure.

Trending posts
You might also like