# \_score not as I'd expect

**URL:** <https://discuss.elastic.co/t/score-not-as-id-expect/106303>\
**Category:** Elasticsearch\
**Created:** [November 3, 2017, 12:15pm UTC](https://discuss.elastic.co/t/score-not-as-id-expect/106303 "2017-11-03T12:15:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bilpor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bilpor/32/24043_2.png) [@bilpor](https://discuss.elastic.co/u/bilpor)\
**Post date:** [November 3, 2017, 12:15pm UTC](https://discuss.elastic.co/t/score-not-as-id-expect/106303/1 "2017-11-03T12:15:20Z")

</div>

Hi All,

I have created an index in Elasticsearch. Using Kibana, I performed a search of a field for a particular word. Kibana returned me the expected results, but the \_score for each record isn't what I would have expected e.g. One record had the word only once in it's text and another had it twice. The one that had it only once gave a score of 6.33 whilst the one with 2 gave a score of 5.726. Other returned records where the word was only in the text once returned scores of 5.968, 5.379 etc. I thought it might have been taking into account letter casing, but changing the case on the search made no difference. Can someone explain to the how the \_score is obtained? I'd have thought that all those records with only one occurrence for instance would all have had the same \_score.

Thanks  
Bill

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 3, 2017, 1:54pm UTC](https://discuss.elastic.co/t/score-not-as-id-expect/106303/2 "2017-11-03T13:54:19Z")

</div>

If you add `"explain": true` in you query you will get those details. Bit complicated though.

In short: what is taken into account:

- frequency of term you are searching for within your document field: the more, the better. But be aware that text is analyzed before being indexed
- frequency of term you are searching for within the full index: the lesser, the better.
- size of the term

If you want to leverage the casing, you can index the same text using 2 different analyzers: standard analyzer and one custom which just uses a standard tokenizer. Then search using a bool query and 2 should clauses: one on the lowercased field (standard analyzer) and one on the preserved case field (custom analyzer).

It will give you on top of the list the ones which matches with exact case.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [November 3, 2017, 6:35pm UTC](https://discuss.elastic.co/t/score-not-as-id-expect/106303/3 "2017-11-03T18:35:56Z")

</div>

Don't forget about the number of shards and IDF values

---

<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:** [December 1, 2017, 6:36pm UTC](https://discuss.elastic.co/t/score-not-as-id-expect/106303/4 "2017-12-01T18:36:07Z")

</div>

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