# Query string different score for similar document

**URL:** <https://discuss.elastic.co/t/query-string-different-score-for-similar-document/102243>\
**Category:** Elasticsearch\
**Created:** [September 29, 2017, 10:26am UTC](https://discuss.elastic.co/t/query-string-different-score-for-similar-document/102243 "2017-09-29T10:26:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prashant\_Agrawal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_agrawal/32/74982_2.png) [@Prashant\_Agrawal](https://discuss.elastic.co/u/Prashant_Agrawal)\
**Post date:** [September 29, 2017, 10:26am UTC](https://discuss.elastic.co/t/query-string-different-score-for-similar-document/102243/1 "2017-09-29T10:26:25Z")

</div>

Hi All,

I was doing some analysis with query string query and what I have come across is that for the same / Similar query I am getting different scores. See the details as below :

```
POST prashant/test
{
  "title" : "Downtown"
}

POST prashant/test
{
  "title" : "Downtown"
}
POST prashant/test
{
  "title" : "Downtown"
}

POST prashant/test
{
  "title" : "Downtown"
}

```

Now I am running a query to search as :

```
POST prashant/_search
{
  "from": 0,
  "size": 50,
  "query": {
    "bool": {
      "should": [
        {
          "query_string": {
            "fields": [
              "title"
            ],
            "query": "downtown",
            "allow_leading_wildcard": true
          }
        },
        {
          "multi_match": {
            "type": "phrase_prefix",
            "fields": [
              "title"
            ],
            "boost": 10,
            "query": "downtown"
          }
        }
      ]
    }
  },
  "_source": [
    "title"
  ]
}

```

And output of above query is :

> ```
> "hits": {
> "total": 4,
> "max_score": 3.1645029,
> "hits": [
> {
> "_index": "prashant",
> "_type": "test",
> "_id": "AV7NJ2PBko4-g528WSa6",
> "_score": 3.1645029,
> "_source": {
> "title": "Downtown"
> }
> },
> {
> "_index": "prashant",
> "_type": "test",
> "_id": "AV7NJ3Dnko4-g528WSa8",
> "_score": 3.1645029,
> "_source": {
> "title": "Downtown"
> }
> },
> {
> "_index": "prashant",
> "_type": "test",
> "_id": "AV7NJ2o3ko4-g528WSa7",
> "_score": 2.0055373,
> "_source": {
> "title": "Downtown"
> }
> },
> {
> "_index": "prashant",
> "_type": "test",
> "_id": "AV7NJ3bnko4-g528WSa9",
> "_score": 2.0055373,
> "_source": {
> "title": "Downtown"
> }
> }
> ] 
> 
> ```

So, here the issue or concern which I have is that all 4 document has only one field with same value as Downtown , and when I am searching then why these documents are getting different score ?

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [October 6, 2017, 7:01am UTC](https://discuss.elastic.co/t/query-string-different-score-for-similar-document/102243/2 "2017-10-06T07:01:17Z")

</div>

The score of each document is computed in the local shards from the statistics present in the shards. Metrics like average size of documents and frequency of the term are local per shards so the same content can have different scores. If you want to align the scores of each shard you can use the `dfs_query_then_fetch` search type:

> **[Understanding "Query Then Fetch" vs "DFS Query Then Fetch"
	  	 | Elastic](https://www.elastic.co/blog/understanding-query-then-fetch-vs-dfs-query-then-fetch)**
>
> In our last article on starts-with phrase matching, we ran into a situation where the returned scores were suspicious. As a refresher, here is the query in question:$ curl -XGET localhost:9200/startsw...

  
... which computes the distributed term frequencies.

---

<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 3, 2017, 7:01am UTC](https://discuss.elastic.co/t/query-string-different-score-for-similar-document/102243/3 "2017-11-03T07:01:25Z")

</div>

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