What this thread does
Do first: run GET /products/_mapping and inspect whether the product name has a populated keyword subfield before changing boosts.
Short answer
As of November 2026, target Elasticsearch 8.19.0 syntax, anchored by its release record and notes. Use text for recall and normalized keyword for term-level queries. Boosts express preference; strict exact-first ordering needs explicit score tiers and descending score order.
Choose / don't choose
- Keyword term: choose for equality of the whole name under a deliberate normalization policy. Don't run term against analyzed text expecting original whole-field equality (term query).
- Analyzed phrase: choose when a phrase query over analyzed text is intended; don't treat phrase matching as whole-field equality (phrase query).
- Fixed score tiers: choose if every exact product must precede every loose hit; don't choose if BM25 relevance must order documents within the tiers without additional design (function score).
Not for: MongoDB query indexing; see mongodb-query-slow-with-many-documents-compound-index-equality-sort-range.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
name.type / name.fields.exact.type | text plus keyword subfield; existing documents do not gain new multi-field values automatically | Elasticsearch 8.19 | multi-fields |
normalizer | lowercase on the keyword field if case-insensitive whole-name equality is intended; runs at indexing and term-query time | Elasticsearch 8.19 | normalizer |
term.boost | Default 1.0; a value greater than 1 increases preference. Tune against judged names. | Elasticsearch 8.19 | term |
bool.minimum_should_match | Explicit 1 for the number of required should-clause matches; default drops to 0 when must/filter exists | Elasticsearch 8.19 | bool |
match.fuzziness | AUTO only on the broader text clause when typo recall is wanted | Elasticsearch 8.19 | match |
score_mode / boost_mode | max / replace for explicit exact and loose weight tiers, ignoring the query score | Elasticsearch 8.19 | function score |
Alias must_exist | true to fail the entire action list if a single action fails | Elasticsearch 8.19 | aliases |
Order of operations
1. Confirm the server line with GET / (cluster info) and inspect the mapping. 2. For a replacement index, use the relevant mapping below. Keep keyword unnormalized instead when case is meaningful (multi-fields, normalizer).
{"mappings":{"properties":{"name":{"type":"text","fields":{"exact":{"type":"keyword","normalizer":"lowercase"}}}}}}
3. Combine three should clauses: term on name.exact, match_phrase on name, and broad match on name. Example starting weights are 10, 3 and 1 respectively, not defaults or a ranking guarantee. Keep access/category/stock filters in the same bool with minimum_should_match 1. Substitute the same input into each clause (bool, term, phrase).
{"query":{"bool":{"should":[{"term":{"name.exact":{"value":"Trail Shoe","boost":10}}},{"match_phrase":{"name":{"query":"Trail Shoe","boost":3}}},{"match":{"name":{"query":"Trail Shoe","boost":1,"fuzziness":"AUTO"}}}],"minimum_should_match":1}}}
4. If strict exact-first order is required, wrap the candidate query in function_score with functions: exact-term filter weight 2 and match_all weight 1; use score_mode max and boost_mode replace. Descending score gives exact=2, other=1, discarding relevance differences within tiers. Add a stable tie-breaker for duplicates; field-first sorts or later scoring can override the policy (combination rules). 5. Create destination mappings/settings before _reindex, which does not copy them. Pause writes or finish update/delete catch-up before cutover. Refresh, then compare counts, sample names and exact/longer-name/typo ranking (reindex). 6. Switch the application alias by removing old and adding new in one _aliases action list with must_exist true. Retain the old index for rollback (aliases).
Known failures and fixes
| Error or symptom | Cause | Fix | Source |
|---|---|---|---|
exact matches seem to be having a lower score | Whole-name equality may be absent; loose clauses or whole-index boosts may dominate | Use the final query in POST /<index>/_explain/<id> for both exact and loose hits. Inspect matched, value and nested description/details for each scoring contribution. Add the exact clause or fixed tiers as the policy requires. | ParisaMoghaddas, October 31, 2022, explain |
| Existing documents miss the new exact clause | A newly added multi-field has no historical values, or analysis differs from the intended tokens | Populate/reindex old documents; use _analyze with the actual field/analyzer and keyword normalizer on both input and stored-name examples. Then repeat the term/explain checks. | multi-fields, analyze |
Missing
- No catalog relevance judgments or production query are given, so 10/3/1 are illustrative weights. Use judged queries or explicit tiers. Hybrid reranking needs a separate policy.
Checked
2026-11-12; Elasticsearch 8.19.0 syntax; release, mapping, query, normalizer, explain/analyze, reindex and alias references plus ParisaMoghaddas report read. No index or search commands executed.
Additional sources read: field-first sorts.
Started from a post by @Elastic, packaged by the editor. Original post