# Query scores are different when search on the same title

**URL:** <https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082>\
**Category:** Elasticsearch\
**Created:** [November 1, 2017, 6:46pm UTC](https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082 "2017-11-01T18:46:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![niceliubing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niceliubing/32/23666_2.png) [@niceliubing](https://discuss.elastic.co/u/niceliubing)\
**Post date:** [November 1, 2017, 6:46pm UTC](https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082/1 "2017-11-01T18:46:06Z")

</div>

I have two records with same book titles.

PUT books/book/2  
{  
"title" : "Nineteen Eighty-Four",  
"reader\_rating" : 4.0,  
"author" : "John Steinbeck"  
}

PUT books/book/3  
{  
"title" : "Nineteen Eighty-Four",  
"reader\_rating" : 4.5,  
"author" : "Joseph Heller"  
}

When I query by title, I got different scores on those two records. Can anyone explain why their score are different scores? I only have **one node**.

GET /\_search  
{  
"query": {  
"match" : {  
"title" : "Nineteen Eighty-Four"  
}  
}  
}

"hits": [  
{  
"\_index": "books",  
"\_type": "book",  
"\_id": "2",  
**"\_score": 1.4820051,**  
"\_source": {  
"title": "Nineteen Eighty-Four",  
"reader\_rating": 4,  
"author": "John Steinbeck"  
}  
},  
{  
"\_index": "books",  
"\_type": "book",  
"\_id": "3",  
**"\_score": 0.7594807,**  
"\_source": {  
"title": "Nineteen Eighty-Four",  
"reader\_rating": 4.5,  
"author": "Joseph Heller"  
}  
}]

Thanks a lot.

---

<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 1, 2017, 9:32pm UTC](https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082/2 "2017-11-01T21:32:24Z")

</div>

You have only one node, but how many shards? IDF values are per shard, so  
you might be experiencing different IDF values for the terms.

You can always enable explanations and see where the different is:  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-explain.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-explain.html)

Another solution is to use a distributed scoring mode and see if the scores  
differ. If they are the same, then it is the IDF value that is causing the  
discrepancy:  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-search-type.html#dfs-query-then-fetch](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-request-search-type.html#dfs-query-then-fetch)

Cheers,

Ivan

---

<div class="post-metadata">

**Author:** ![niceliubing](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niceliubing/32/23666_2.png) [@niceliubing](https://discuss.elastic.co/u/niceliubing)\
**Post date:** [November 2, 2017, 6:36pm UTC](https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082/3 "2017-11-02T18:36:00Z")

</div>

Thanks Ivan.

True I have five shards on my node. If I use one shard only, their scores are the same.

Bing

---

<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 2, 2017, 7:15pm UTC](https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082/4 "2017-11-02T19:15:36Z")

</div>

Common cause for discrepancies while testing. You can enable distributed  
term frequencies (only a slight performance hit), but in general, IDF  
values normalize as you add more non-trivial content. If you have only a  
handful of test documents, then IDF values will almost always be different  
(with the default 5 shards).

---

<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:** [November 30, 2017, 7:15pm UTC](https://discuss.elastic.co/t/query-scores-are-different-when-search-on-the-same-title/106082/5 "2017-11-30T19:15:37Z")

</div>

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