# Searching in same condition but different scoring

**URL:** <https://discuss.elastic.co/t/searching-in-same-condition-but-different-scoring/73319>\
**Category:** Elasticsearch\
**Created:** [January 31, 2017, 7:27am UTC](https://discuss.elastic.co/t/searching-in-same-condition-but-different-scoring/73319 "2017-01-31T07:27:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [January 31, 2017, 7:27am UTC](https://discuss.elastic.co/t/searching-in-same-condition-but-different-scoring/73319/1 "2017-01-31T07:27:42Z")

</div>

I use ES5.1.1  
query is as below

```auto
index/type/_search
{ 
  "query": {
    "term": {
      "status": "ZA"
    }
  }
}

```

Conditions  
all data have status field.  
ZA is full match value.

result by explain API

```auto
{
  "_index": "index",
  "_type": "type",
  "_id": "1010999",
  "matched": true,
  "explanation": {
    "value": 6.4028416,
    "description": "sum of:",
    "details": [
      {
        "value": 6.4028416,
        "description": "weight(status:ZA in 0) [PerFieldSimilarity], result of:", ----(status:ZA in 0) is different from the other result.
        "details": [
          {
            "value": 6.4028416,
            "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
            "details": [
              {
                "value": 6.4028416,
                "description": "idf(docFreq=151, docCount=91438)",
                "details": []
              },
              {
                "value": 1,
                "description": "tfNorm, computed from:",
                "details": [
                  {
                    "value": 1,
                    "description": "termFreq=1.0",
                    "details": []
                  },
                  {
                    "value": 1.2,
                    "description": "parameter k1",
                    "details": []
                  },
                  {
                    "value": 0,
                    "description": "parameter b (norms omitted for field)",
                    "details": []
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "value": 0,
        "description": "match on required clause, product of:",
        "details": [
          {
            "value": 0,
            "description": "# clause",
            "details": []
          },
          {
            "value": 1,
            "description": "*:*, product of:",
            "details": [
              {
                "value": 1,
                "description": "boost",
                "details": []
              },
              {
                "value": 1,
                "description": "queryNorm",
                "details": []
              }
            ]
          }
        ]
      }
    ]
  }
}

```

```auto
{
  "_index": "index",
  "_type": "type",
  "_id": "1112675",
  "matched": true,
  "explanation": {
    "value": 6.345958,
    "description": "sum of:",
    "details": [
      {
        "value": 6.345958,
        "description": "weight(status:ZA in 10849) [PerFieldSimilarity], result of:", ----(status:ZA in 10849) part is different from the other result.
        "details": [
          {
            "value": 6.345958,
            "description": "score(doc=10849,freq=1.0 = termFreq=1.0\n), product of:",
            "details": [
              {
                "value": 6.345958,
                "description": "idf(docFreq=163, docCount=93224)",
                "details": []
              },
              {
                "value": 1,
                "description": "tfNorm, computed from:",
                "details": [
                  {
                    "value": 1,
                    "description": "termFreq=1.0",
                    "details": []
                  },
                  {
                    "value": 1.2,
                    "description": "parameter k1",
                    "details": []
                  },
                  {
                    "value": 0,
                    "description": "parameter b (norms omitted for field)",
                    "details": []
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "value": 0,
        "description": "match on required clause, product of:",
        "details": [
          {
            "value": 0,
            "description": "# clause",
            "details": []
          },
          {
            "value": 1,
            "description": "*:*, product of:",
            "details": [
              {
                "value": 1,
                "description": "boost",
                "details": []
              },
              {
                "value": 1,
                "description": "queryNorm",
                "details": []
              }
            ]
          }
        ]
      }
    ]
  }
}

```

Result scores are different.  
Is there any reason that scores are different?

Any tips??

---

<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:** [January 31, 2017, 7:54am UTC](https://discuss.elastic.co/t/searching-in-same-condition-but-different-scoring/73319/2 "2017-01-31T07:54:09Z")

</div>

My guess is that the documents reside in different shards and therefore  
have different IDF values for the same term. Try using dfs-query-then-fetch  
to see if that changes anything.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html#dfs-query-then-fetch](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html#dfs-query-then-fetch)

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [January 31, 2017, 8:40am UTC](https://discuss.elastic.co/t/searching-in-same-condition-but-different-scoring/73319/3 "2017-01-31T08:40:28Z")

</div>

Thank you for reply.

It helped me a lot to understand why score was different.

I found this article as well.  
To help someone who gets same issue, here is the answer as well.

> **[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...

---

<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:** [February 28, 2017, 8:40am UTC](https://discuss.elastic.co/t/searching-in-same-condition-but-different-scoring/73319/4 "2017-02-28T08:40:42Z")

</div>

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