This is why?

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 ?

You meant _score.

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

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

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

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

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

sorry, The editor has length limit

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": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
               {
                  "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": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      },
........
{
        "_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": []
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "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 !

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.

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

donot change mapping , this result can be optimized?

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

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