AI Hints
Home›Elasticsearch Tutorial›Relevance and Scoring
Elasticsearch · Lesson 63 of 120

Field Boosting

Name matters more.

⏱ 2 min read▶ Video at 59:36🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

A match in the product name is a much stronger signal than a match in a long description. If someone types boots, products called boots should win. Field boosting says so.

  • Name beats description
  • boots → boots first
  • Boost fields

Without and with a boost

Both searches look for rain, in the name and the description. The second one boosts the name five times. Run it. Without the boost, a backpack with a rain cover comes first. With it, the rain jackets take the top three places.

Dev Tools Consoletext
GET products/_search?filter_path=hits.hits._source.name
{ "query": { "multi_match": { "query": "rain",
    "fields": ["name", "description"] } }, "size": 3 }

GET products/_search?filter_path=hits.hits._source.name
{ "query": { "multi_match": { "query": "rain",
    "fields": ["name^5", "description"] } }, "size": 3 }
Output
# GET products/_search 200 OK
{
  "hits": {
    "hits": [
      {"_source": {"name": "Daypack 22L Hiking Backpack"}},
      {"_source": {"name": "Cloudburst Rain Jacket"}},
      {"_source": {"name": "Storm Rain Jacket"}}
    ]
  }
}

# GET products/_search 200 OK
{
  "hits": {
    "hits": [
      {"_source": {"name": "Storm Rain Jacket"}},
      {"_source": {"name": "Breeze Rain Jacket"}},
      {"_source": {"name": "Cloudburst Rain Jacket"}}
    ]
  }
}
Also uses _load
catalog

Boosting tips

Use the caret in multi match, or boost in a single query. Start with small numbers, like two or three. Test with real searches, and explain. Too much boosting can bury good results.

keyvalue
^ in fieldsname^3
boost paramin any query
Start small2 to 3
Checkreal searches

Summary

Boost the fields that matter most, like the name, with a caret. Keep boosts small, and test them. Next, mixing popularity into the score.

Key takeaways
  • name^3
  • Small boosts
  • Test
Next up: function_score — popularity counts