# This is why?

**URL:** <https://discuss.elastic.co/t/this-is-why/91594>\
**Category:** Elasticsearch\
**Created:** [July 3, 2017, 6:49am UTC](https://discuss.elastic.co/t/this-is-why/91594 "2017-07-03T06:49:44Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 6:49am UTC](https://discuss.elastic.co/t/this-is-why/91594/1 "2017-07-03T06:49:44Z")

</div>

```auto
POST /index_name/_search
{
  "from": 0,
  "size": 100, 
  "query": {
    "bool": {
      "should": [
        
        {
          "match": {
            "shop_name": "麦吉之源"
          }
        },
        {
          "match": {
            "hotel_name": "麦吉之源"
          }
        }
      ]
    }
  }
}

query result:

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "hits": {
    "total": 28,
    "max_score": 25.113892,
    "hits": [
      {
        "_index": "index_name",
        "_type": "food",
        "_id": "25795",
        "_score": 25.113892,
        "_source": {
          "sourceID": 729854,
          "dataID": 25795,
          "shop_name": "麦吉之源",
          "city": "茂县"
        }
      },

........
   {
        "_index": "index_name",
        "_type": "hotel",
        "_id": "1",
        "_score": 0.56727815,
        "_source": {
          "sourceID": 733686,
          "dataID": 1,
          "hotel_name": "麦吉之源",
          "city": "茂县"
        }
      }
    ]
  }
}

```

**this \_score why such a big difference ?**

---

<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:** [July 3, 2017, 7:05am UTC](https://discuss.elastic.co/t/this-is-why/91594/2 "2017-07-03T07:05:18Z")

</div>

You meant \_score.

It's due to sharding. Change the number of shards to 1.

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 7:08am UTC](https://discuss.elastic.co/t/this-is-why/91594/3 "2017-07-03T07:08:50Z")

</div>

```auto
PUT /index_name
{
  "mappings": {
    "food": {
      "numeric_detection": true,
      "properties": {
        "sourceID":{
          "store": true,
          "type": "integer"
        },
        "dataID":{
          "store": true,
          "type": "integer"
        },
        "shop_name":{
            "type":"text",
            "analyzer": "ik_max_word",
            "index_options": "offsets"
        },
        "city":{
          "type":"text",
          "index": "not_analyzed",
          "index_options": "offsets"
        }
      }
    },
    "hotel" :{
      "numeric_detection": true,
      "properties": {
        "sourceID":{
          "store": true,
          "type": "integer"
        },
        "dataID":{
          "store": true,
          "type": "integer"
        },
        "hotel_name":{
            "type":"text",
            "analyzer": "ik_max_word",
            "index_options": "offsets"
        },
        "city":{
          "type":"text",
          "index": "not_analyzed",
          "index_options": "offsets"
        }
      }
    }
  },
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1
  }
}

```

the number of shards is 1

---

<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:** [July 3, 2017, 9:43am UTC](https://discuss.elastic.co/t/this-is-why/91594/4 "2017-07-03T09:43:55Z")

</div>

Can you add `"explain": true` in your query?

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 10:17am UTC](https://discuss.elastic.co/t/this-is-why/91594/5 "2017-07-03T10:17:52Z")

</div>

![](https://us1.discourse-cdn.com/elastic/original/3X/8/c/8c5e670fe9ce59fb6f8c881d2c65c00ec6f4c7f0.png)

 ![](https://us1.discourse-cdn.com/elastic/original/3X/c/a/cade0156b66a035fcf4ba8214638f98846e3ab4e.png) ![](https://us1.discourse-cdn.com/elastic/original/3X/b/4/b407b736b8a4f78d36ac8b6372e74ddc4271fabc.png) ![](https://us1.discourse-cdn.com/elastic/original/3X/5/0/50cc8895606a9a89befef888799a868047e0bf70.png)

**because docCount? type food is 950,type hotel is 3**

---

<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:** [July 3, 2017, 10:32am UTC](https://discuss.elastic.co/t/this-is-why/91594/6 "2017-07-03T10:32:32Z")

</div>

Please don't paste images but text. This is not really readable.

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 10:35am UTC](https://discuss.elastic.co/t/this-is-why/91594/7 "2017-07-03T10:35:51Z")

</div>

**sorry, The editor has length limit**

```auto
hits": {
    "total": 28,
    "max_score": 25.113892,
    "hits": [
      {
        "_shard": "[index_name][0]",
        "_node": "z2ZEP3aRQm69TJKDtI01fg",
        "_index": "index_name",
        "_type": "food",
        "_id": "25795",
        "_score": 25.113892,
        "_source": {
          "sourceID": 729854,
          "dataID": 25795,
          "shop_name": "麦吉之源",
          "city": "茂县"
        },
        "_explanation": {
          "value": 25.113892,
          "description": "sum of:",
          "details": [
            {
              "value": 25.113892,
              "description": "sum of:",
              "details": [
                {
                  "value": 7.754879,
                  "description": "weight(shop_name:麦吉 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 7.754879,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 6.452049,
                          "description": "idf(docFreq=1, docCount=950)",
                          "details": []
                        },
                        {
                          "value": 1.201925,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 6.7873683,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "value": 4.802067,
                  "description": "weight(shop_name:麦 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 4.802067,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 3.9953132,
                          "description": "idf(docFreq=17, docCount=950)",
                          "details": []
                        },
                        {
                          "value": 1.201925,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 6.7873683,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },

```

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 10:36am UTC](https://discuss.elastic.co/t/this-is-why/91594/8 "2017-07-03T10:36:28Z")

</div>

```auto
               {
                  "value": 5.820455,
                  "description": "weight(shop_name:吉 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 5.820455,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 4.842611,
                          "description": "idf(docFreq=7, docCount=950)",
                          "details": []
                        },
                        {
                          "value": 1.201925,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 6.7873683,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "value": 6.7364907,
                  "description": "weight(shop_name:之源 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 6.7364907,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 5.604751,
                          "description": "idf(docFreq=3, docCount=950)",
                          "details": []
                        },
                        {
                          "value": 1.201925,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 6.7873683,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      },
........

```

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 10:37am UTC](https://discuss.elastic.co/t/this-is-why/91594/9 "2017-07-03T10:37:33Z")

</div>

```auto
{
        "_shard": "[index_name][0]",
        "_node": "z2ZEP3aRQm69TJKDtI01fg",
        "_index": "index_name",
        "_type": "hotel",
        "_id": "1",
        "_score": 0.56727815,
        "_source": {
          "sourceID": 733686,
          "dataID": 1,
          "hotel_name": "麦吉之源",
          "city": "茂县"
        },
        "_explanation": {
          "value": 0.56727815,
          "description": "sum of:",
          "details": [
            {
              "value": 0.56727815,
              "description": "sum of:",
              "details": [
                {
                  "value": 0.14181954,
                  "description": "weight(hotel_name:麦吉 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 0.14181954,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 0.13353139,
                          "description": "idf(docFreq=3, docCount=3)",
                          "details": []
                        },
                        {
                          "value": 1.0620689,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 4.6666665,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "value": 0.14181954,
                  "description": "weight(hotel_name:麦 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 0.14181954,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 0.13353139,
                          "description": "idf(docFreq=3, docCount=3)",
                          "details": []
                        },
                        {
                          "value": 1.0620689,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 4.6666665,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },

```

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 3, 2017, 10:38am UTC](https://discuss.elastic.co/t/this-is-why/91594/10 "2017-07-03T10:38:44Z")

</div>

```auto
                {
                  "value": 0.14181954,
                  "description": "weight(hotel_name:吉 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 0.14181954,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 0.13353139,
                          "description": "idf(docFreq=3, docCount=3)",
                          "details": []
                        },
                        {
                          "value": 1.0620689,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 4.6666665,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "value": 0.14181954,
                  "description": "weight(hotel_name:之源 in 0) [PerFieldSimilarity], result of:",
                  "details": [
                    {
                      "value": 0.14181954,
                      "description": "score(doc=0,freq=1.0 = termFreq=1.0\n), product of:",
                      "details": [
                        {
                          "value": 0.13353139,
                          "description": "idf(docFreq=3, docCount=3)",
                          "details": []
                        },
                        {
                          "value": 1.0620689,
                          "description": "tfNorm, computed from:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0",
                              "details": []
                            },
                            {
                              "value": 1.2,
                              "description": "parameter k1",
                              "details": []
                            },
                            {
                              "value": 0.75,
                              "description": "parameter b",
                              "details": []
                            },
                            {
                              "value": 4.6666665,
                              "description": "avgFieldLength",
                              "details": []
                            },
                            {
                              "value": 4,
                              "description": "fieldLength",
                              "details": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      },

```

**because docCount? type food is 950,type hotel is 3**

**thank you !**

---

<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:** [July 3, 2017, 12:02pm UTC](https://discuss.elastic.co/t/this-is-why/91594/11 "2017-07-03T12:02:32Z")

</div>

Ha! I did not notice at the beginning that you had 2 should clauses on different fields.

Indeed the distribution of the terms within the indices differs.  
Lucene relevancy algorithm by default tries to find documents where the terms you are looking for are frequent in the document but rare in the whole index.

Which is probably the case here. `shop_name` `麦吉之源` is probably a very rare term in your index where `麦吉之源` is more frequent in `hotel_name` field.

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 4, 2017, 1:59am UTC](https://discuss.elastic.co/t/this-is-why/91594/12 "2017-07-04T01:59:21Z")

</div>

Aha! I've learned .  
thank you very much!

---

<div class="post-metadata">

**Author:** ![qin](https://avatars.discourse-cdn.com/v4/letter/q/91b2a8/32.png) [@qin](https://discuss.elastic.co/u/qin)\
**Post date:** [July 4, 2017, 7:42am UTC](https://discuss.elastic.co/t/this-is-why/91594/14 "2017-07-04T07:42:29Z")

</div>

donot change mapping , this result can be optimized?

---

<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:** [July 4, 2017, 7:54am UTC](https://discuss.elastic.co/t/this-is-why/91594/15 "2017-07-04T07:54:08Z")

</div>

You can always boost some fields and make their content more relevant than the content of other fields.

---

<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:** [August 1, 2017, 7:54am UTC](https://discuss.elastic.co/t/this-is-why/91594/16 "2017-08-01T07:54:20Z")

</div>

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