# Odd scoring behavior

**URL:** <https://discuss.elastic.co/t/odd-scoring-behavior/120932>\
**Category:** Elasticsearch\
**Created:** [February 21, 2018, 8:44pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932 "2018-02-21T20:44:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![atulsudhalkar](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@atulsudhalkar](https://discuss.elastic.co/u/atulsudhalkar)\
**Post date:** [February 21, 2018, 8:44pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/1 "2018-02-21T20:44:47Z")

</div>

I’m creating an index via the following:

{"mappings": {"Student": {"properties": {"skills": {"type":"text","analyzer":"english"}}}}}

Then I’m adding three documents to it:

{"index":{"\_id":"unr\_nedra\_north"}}  
{"id":"unr\_nedra\_north","fullName":"Nedra North","skills":"python;java;react;html;front-end development;databases","idAsString":"unr\_nedra\_north"}  
{"index":{"\_id":"unr\_neha\_gurusiddaiah"}}  
{"id":"unr\_neha\_gurusiddaiah","fullName":"Neha Gurusiddaiah","skills":"python;java;react;html;front-end development;databases","idAsString":"unr\_neha\_gurusiddaiah"}  
{"index":{"\_id":"wsu\_ward\_wild"}}  
{"id":"wsu\_ward\_wild","fullName":"Ward Wild","skills":"python;java;react;html;front-end development;databases","idAsString":"wsu\_ward\_wild"}

As you can see, all three documents have identical “skills” field values. And yet, when I search the index for keyword “java” with this query:

{  
"explain": true,  
"query": {"match":{"skills" : "java"}}  
}

I get different scores for each hit! I can't paste the full results with explanation due to character limits, but the scores are 0.2876821, 0.18232156 and 0.18232156 respectively. Can anyone point me to what I'm doing wrong? I'm NOT using any custom scoring.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 21, 2018, 8:48pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/2 "2018-02-21T20:48:29Z")

</div>

How many shards do the index have? Are the two documents with the same score by any chance located in the same shard?

---

<div class="post-metadata">

**Author:** ![atulsudhalkar](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@atulsudhalkar](https://discuss.elastic.co/u/atulsudhalkar)\
**Post date:** [February 21, 2018, 9:01pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/3 "2018-02-21T21:01:36Z")

</div>

Many thanks for the quick response!

Only one shard—the index has only 12 docs. We’re still in the pre-alpha phase of our product development. I can give you access to the index, if you want to take a look…

--atul

Atul Sudhalkar  
Principal Architect

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 22, 2018, 8:55am UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/4 "2018-02-22T08:55:53Z")

</div>

Preparing a minimal recreating script is generally recommended. I ran the following, and had all 3 documents return the same score on Elasticsearch 6.2.2:

```auto
PUT test
{
  "settings" : {
      "number_of_shards" : 1
  },
  "mappings": {
    "Student": {
      "properties": {
        "skills": {
          "type":"text",
          "analyzer":"english"
        }
      }
    }
  }
}

PUT test/Student/unr_nedra_north
{"id":"unr_nedra_north","fullName":"Nedra North","skills":"python;java;react;html;front-end development;databases","idAsString":"unr_nedra_north"}

PUT test/Student/unr_neha_gurusiddaiah
{"id":"unr_neha_gurusiddaiah","fullName":"Neha Gurusiddaiah","skills":"python;java;react;html;front-end development;databases","idAsString":"unr_neha_gurusiddaiah"}

PUT test/Student/wsu_ward_wild
{"id":"wsu_ward_wild","fullName":"Ward Wild","skills":"python;java;react;html;front-end development;databases","idAsString":"wsu_ward_wild"}

POST test/_refresh

GET test/_search
{
  "explain": true,
  "query": {"match":{"skills" : "java"}}
}

```

---

<div class="post-metadata">

**Author:** ![atulsudhalkar](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@atulsudhalkar](https://discuss.elastic.co/u/atulsudhalkar)\
**Post date:** [February 22, 2018, 6:18pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/5 "2018-02-22T18:18:11Z")

</div>

1. Point taken: in future, I'll prepare a script like you posted above.
2. I re-created the index with one shard (as you suggested), and that worked!
3. As you might imagine, I first re-created my problem with minimal fields so I could focus questions on this forum. When I tried the single-shard index create statement in my full app, it worked there as well. But if I use 2 or any higher number of shards, it gets weird. I take it that's a feature, not a bug? Any way to make this more robust across multiple shards?

---

<div class="post-metadata">

**Author:** ![atulsudhalkar](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@atulsudhalkar](https://discuss.elastic.co/u/atulsudhalkar)\
**Post date:** [February 22, 2018, 6:18pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/6 "2018-02-22T18:18:30Z")

</div>

I forgot to add: thanks a ton for the prompt help!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 22, 2018, 6:38pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/7 "2018-02-22T18:38:02Z")

</div>

[This part of the docs](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/consistent-scoring.html) may help.

---

<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:** [March 22, 2018, 6:38pm UTC](https://discuss.elastic.co/t/odd-scoring-behavior/120932/8 "2018-03-22T18:38:21Z")

</div>

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