在function_score上期待另一个结果(得分)

时间:2018-09-25 13:29:12

标签: elasticsearch

我想知道查询的得分。我在文档的权重字段上使用了sudo apic status。如果我搜索“ wien”一词,则两个文档来自两个索引。

这是我的查询:

function_score

另一方面,我的结果:

GET _all/_search
{
 "query": {
  "function_score" : {
    "query" : {
      "bool" : {
        "should" : [
          {
            "bool" : {
              "must" : [
                {
                  "multi_match" : {
                    "query" : "wien",
                    "fields" : [
                      "city.name_de^1.0"
                    ],
                    "type" : "best_fields",
                    "operator" : "OR",
                    "slop" : 0,
                    "fuzziness" : "0",
                    "prefix_length" : 0,
                    "max_expansions" : 50,
                    "lenient" : false,
                    "zero_terms_query" : "NONE",
                    "boost" : 1.0
                  }
                }
              ],
              "filter" : [
                {
                  "term" : {
                    "_index" : {
                      "value" : "city",
                      "boost" : 1.0
                    }
                  }
                },
                {
                  "term" : {
                    "enabled" : {
                      "value" : true,
                      "boost" : 1.0
                    }
                  }
                }
              ],
              "should" : [
                {
                  "bool" : {
                    "disable_coord" : false,
                    "adjust_pure_negative" : true,
                    "boost" : 1.0
                  }
                },
                {
                  "bool" : {
                    "disable_coord" : false,
                    "adjust_pure_negative" : true,
                    "boost" : 1.0
                  }
                }
              ],
              "disable_coord" : false,
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          },
          {
            "bool" : {
              "must" : [
                {
                  "multi_match" : {
                    "query" : "wien",
                    "fields" : [
                      "servicename.name_de^1.0"
                    ],
                    "type" : "best_fields",
                    "operator" : "OR",
                    "slop" : 0,
                    "fuzziness" : "0",
                    "prefix_length" : 0,
                    "max_expansions" : 50,
                    "lenient" : false,
                    "zero_terms_query" : "NONE",
                    "boost" : 1.0
                  }
                }
              ],
              "filter" : [
                {
                  "term" : {
                    "_index" : {
                      "value" : "servicename",
                      "boost" : 1.0
                    }
                  }
                },
                {
                  "term" : {
                    "enabled" : {
                      "value" : true,
                      "boost" : 1.0
                    }
                  }
                }
              ],
              "should" : [
                {
                  "bool" : {
                    "disable_coord" : false,
                    "adjust_pure_negative" : true,
                    "boost" : 1.0
                  }
                }
              ],
              "disable_coord" : false,
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          }
        ],
        "disable_coord" : false,
        "adjust_pure_negative" : true,
        "boost" : 1.0
      }
    },
    "functions" : [
      {
        "filter" : {
          "match_all" : {
            "boost" : 1.0
          }
        },
        "field_value_factor" : {
          "field" : "weight",
          "factor" : 1.0,
          "modifier" : "none"
        }
      }
    ],
    "score_mode" : "multiply",
    "max_boost" : 3.4028235E38,
    "boost" : 1.0
  }
}
}

我不明白为什么"hits": [ { "_index": "city", "_type": "city", "_id": "589", "_score": 377704.28, "_source": { "svno": 589, "city": { "name": "Wien", "name_de": "Wien", "name_it": "Vienna", "name_fr": "Vienne", "name_hu": "Bécs", "name_cs": "Vídeň" }, "regions": [ { "name": "Wien", "name_de": "Wien", "name_it": "Vienne", "name_fr": "Vienna", "name_hu": "Bécs", "name_cs": "Vídeň" } ], "nation": { "name": "Österreich", "name_de": "Österreich", "name_it": "Austria", "name_fr": "Autriche", "name_hu": "Ausztria", "name_cs": "Rakousko" }, "location": { "lat": 48.20827865600586, "lon": 16.373079299926758 }, "weight": 32300 } }, { "_index": "servicename", "_type": "servicename", "_id": "593", "_score": 279269.25, "_source": { "id": "593", "servicename": { "name": "Wien", "name_de": "Wien", "name_it": "Vienne", "name_fr": "Vienna", "name_hu": "Bécs", "name_cs": "Vídeň" }, "city": null, "region": { "svno": 593, "regions": [ { "name": "Wien", "name_de": "Wien", "name_it": "Vienne", "name_fr": "Vienna", "name_hu": "Bécs", "name_cs": "Vídeň" } ], "nation": { "name": "Österreich", "name_de": "Österreich", "name_it": "Austria", "name_fr": "Autriche", "name_hu": "Ausztria", "name_cs": "Rakousko" } }, "theme": null, "contract": null, "enabled": true, "weight": 35300 } } ] 索引的结果比city索引的结果高。 servicename的权重为servicename35300的权重为city

我希望32300文档应该是最好的结果。

您对此有何解释?

0 个答案:

没有答案