# Search Not Applying Scores Properly - Ignoring Boosts

**URL:** https://discuss.elastic.co/t/search-not-applying-scores-properly-ignoring-boosts/348097
**Category:** Elasticsearch
**Created:** [November 28, 2023, 1:26am UTC](https://discuss.elastic.co/t/search-not-applying-scores-properly-ignoring-boosts/348097 "2023-11-28T01:26:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mmobley](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mmobley](https://discuss.elastic.co/u/mmobley)
#### Post date: [November 28, 2023, 1:26am UTC](https://discuss.elastic.co/t/search-not-applying-scores-properly-ignoring-boosts/348097/1 "2023-11-28T01:26:11Z")

</div>

I'm working on a complex query with multiple keyword fields that are weighted differently (one for category, one for brand, etc) but the query seems to be ignoring the boosts and scoring weird. Here's my query:

> **Summary**
>
> `{ "from": 0, "min_score": 5.0, "query": { "bool": { "filter": [{ "match": { "whse": { "query": "9999" } } }, { "bool": { "should": [{ "match": { "partClass": { "query": "Plumbing" } } }, { "match": { "partClass": { "query": "Miscellaneous" } } }] } }, { "term": { "isDiscontinued": { "value": false } } } ], "should": [{ "prefix": { "partNo": { "boost": 20.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "prefix": { "partNo.keyword": { "boost": 20.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "prefix": { "oEM": { "boost": 15.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "prefix": { "oEM.keyword": { "boost": 15.0, "case_insensitive": true, "value": "wolverine brass faucets" } } }, { "match": { "keyword1": { "boost": 15.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword2": { "boost": 14.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword3": { "boost": 13.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword4": { "boost": 20.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword5": { "boost": 11.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword6": { "boost": 10.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword7": { "boost": 9.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword8": { "boost": 8.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword9": { "boost": 7.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword10": { "boost": 6.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword11": { "boost": 5.0, "query": "wolverine brass faucets" } } }, { "match": { "keyword12": { "boost": 4.0, "query": "wolverine brass faucets" } } }, { "match": { "description": { "query": "wolverine brass faucets" } } }] } }, "size": 1000 }`

And here are my mappings:

> **Summary**
>
> ```auto
> {
> "partinfo_20231113_172838": {
> "mappings": {
> "properties": {
> "category": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "description": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "filterValue": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "isDiscontinued": {
> "type": "boolean"
> },
> "keyword1": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword10": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword11": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword12": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword2": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword3": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword4": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword5": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword6": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword7": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword8": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keyword9": {
> "type": "text",
> "analyzer": "customAnalyzerSynonym"
> },
> "keywords": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "make": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "oEM": {
> "type": "text",
> "analyzer": "keyword",
> "index_prefixes": {
> "min_chars": 3,
> "max_chars": 15
> }
> },
> "partClass": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "partNo": {
> "type": "text",
> "analyzer": "keyword",
> "index_prefixes": {
> "min_chars": 3,
> "max_chars": 15
> }
> },
> "restrictionCodes": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "salesYTD": {
> "type": "integer"
> },
> "webURL": {
> "type": "text",
> "fields": {
> "keyword": {
> "type": "keyword",
> "ignore_above": 256
> }
> }
> },
> "whse": {
> "type": "short"
> }
> }
> }
> }
> }
> 
> ```

Can anyone help? I'm looking to score queries based on how many words match (with a little fuzziness) with a weight depending on what field.

---

<div class="post-metadata">

### Author: ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)
#### Post date: [December 7, 2023, 6:29pm UTC](https://discuss.elastic.co/t/search-not-applying-scores-properly-ignoring-boosts/348097/2 "2023-12-07T18:29:19Z")

</div>

Hey @mmobley,

Have you ran the query with `explain: true` in the search body? That should tell you the scoring calculation used.

Another thing to do is to add `_name` to each of your queries: [Boolean query | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html#named-queries)

This way you can see for sure which query matched for each document. Its even better with adding the `include_named_queries_score` parameter, which returns by how much each query contributes to the overall score.

---

<div class="post-metadata">

### Author: ![Abhilash\_B](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhilash_b/32/40270_2.png) [@Abhilash\_B](https://discuss.elastic.co/u/Abhilash_B)
#### Post date: [December 8, 2023, 1:37pm UTC](https://discuss.elastic.co/t/search-not-applying-scores-properly-ignoring-boosts/348097/3 "2023-12-08T13:37:40Z")

</div>

Hey @mmobley,

Can you also share the analyzer config here? Further to what @BenTrent said. I think your search term is getting satisfied by multiple queries which inturn results in a normalized score. `explain: true` parameter as part of your search body is your best friend here.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [January 5, 2024, 1:38pm UTC](https://discuss.elastic.co/t/search-not-applying-scores-properly-ignoring-boosts/348097/4 "2024-01-05T13:38:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
