# Is it normal or a bug that same query has the result with different score?

**URL:** <https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248>\
**Category:** Elastic Search\
**Created:** [December 19, 2024, 11:08pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248 "2024-12-19T23:08:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ginger\_Jiang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginger_jiang/32/140203_2.png) [@Ginger\_Jiang](https://discuss.elastic.co/u/Ginger_Jiang)\
**Post date:** [December 19, 2024, 11:08pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248/1 "2024-12-19T23:08:02Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/7/c/7cbe04ba4de47aaff61c328721da6786a6621397.png)  
I'm working on a project using elk search. I need consistant score of query result for the purpose of consistant search\_after result. However, the score is not consistant given the same query, same index, no change to the index.

Have u came across the same issue?

I'm wondering:

1. Is the score inherently inconsistant for elk? or is this some bug?
2. Is just the absolute score inconsistant? what about the relative score? I mean the ranking/sorting of all query hits would be consistant or inconsistant?

Notes: The score is generated by a sole match\_phrase clause and the version is 8.16.1. This database does not have writing for a while.

---

<div class="post-metadata">

**Author:** ![Dmitry\_S](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@Dmitry\_S](https://discuss.elastic.co/u/Dmitry_S)\
**Post date:** [December 19, 2024, 11:59pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248/2 "2024-12-19T23:59:44Z")

</div>

What do you see in explain mode? It may be useful to compare it side-by-side when final scores are different

```auto
POST _search?explain=true
{
  "query": {
<...>
  }
}

```

---

<div class="post-metadata">

**Author:** ![Ginger\_Jiang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginger_jiang/32/140203_2.png) [@Ginger\_Jiang](https://discuss.elastic.co/u/Ginger_Jiang)\
**Post date:** [December 20, 2024, 3:58pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248/3 "2024-12-20T15:58:34Z")

</div>

Thank u for the suggestion, it's helpful!

I used the explain mode and compare, it looks tf/idf calculation uses different ifd statistics, not sure if it is because different shards responded to the search (we have one primary and one secondary)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c27f85bb077ff527fe5f8aa97542f422f13f7c23.jpeg)

---

<div class="post-metadata">

**Author:** ![Ginger\_Jiang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ginger_jiang/32/140203_2.png) [@Ginger\_Jiang](https://discuss.elastic.co/u/Ginger_Jiang)\
**Post date:** [December 20, 2024, 4:00pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248/4 "2024-12-20T16:00:11Z")

</div>

Does any one know the source of inconsistency?

FYI, the structure of my elk structure is: 3 cluster, 12 shards, each shard has two copies.

I look at one particular result and this result resides in one shard (one primary and one secondary) exactly

---

<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:** [December 20, 2024, 4:25pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248/5 "2024-12-20T16:25:07Z")

</div>

> [@Ginger\_Jiang](#):
>
> not sure if it is because different shards responded to the search (we have one primary and one secondary)

Yes. That's most likely the case here.

What happens if you are using `dfs_query_then_fetch` for `search_type`? See [Search API | Elasticsearch Guide [8.17] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html)

---

<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 17, 2025, 4:25pm UTC](https://discuss.elastic.co/t/is-it-normal-or-a-bug-that-same-query-has-the-result-with-different-score/372248/6 "2025-01-17T16:25:49Z")

</div>

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