代码之家  ›  专栏  ›  技术社区  ›  mnd

从1.7移动到5.4时,Elasticsearch查询结果不同

  •  0
  • mnd  · 技术社区  · 9 年前

    我正在将Elasticsearch实例从1.7升级到5.4.3,并注意到两个系统之间的搜索结果不同,即使使用相同的查询。

    {
      "query": {
        "filtered": {
          "query": {
            "multi_match": {
              "query": "something",
              "fields": [
                "field1",
                "field2",
                "field3"
              ],
              "operator": "and"
            }
          }
        }
      }
    }
    

    Elasticsearch 5.4查询

    {
      "query": {
        "bool": {
          "must": [
            {
              "multi_match": {
                "query": "something",
                "fields": [
                  "field1",
                  "field2",
                  "field3"
                ],
                "operator": "and"
              }
            }
          ]
        }
      }
    }
    

    _explain 最终,我发现评分方式有所不同。此外,此查询包括搜索查询匹配的同义词。

    {
        "_index": "...",
        "_type": "...",
        "_id": "...",
        "matched": true,
        "explanation": {
            "value": 9.963562,
            "description": "max of:",
            "details": [
                {
                    "value": 3.1413355,
                    "description": "sum of:",
                    "details": [
                        {
                            "value": 1.0609967,
                            "description": "weight(field1:something in 13) [PerFieldSimilarity], result of:",
                            "details": [
    ...remainder removed for brevity
    

    解释Elasticsearch 5.4

    {
        "_index": "...",
        "_type": "...",
        "_id": "...",
        "matched": true,
        "explanation": {
            "value": 7.1987557,
            "description": "sum of:",
            "details": [
                {
                    "value": 7.1987557,
                    "description": "max of:",
                    "details": [
                        {
                            "value": 6.659632,
                            "description": "weight(Synonym(field1:something field1:something2 field1:something3) in 113) [PerFieldSimilarity], result of:",
                            "details": [
    ...remainder removed for brevity
    

    问题

    1. 事实上 Elasticsearch 1.7显示的查询 max of sum of 对于计算,它是 对面的 对于Elasticsearch 5.4,指出部分问题?
    1 回复  |  直到 9 年前
        1
  •  0
  •   mnd    9 年前

    默认的“相似性”在Elasticsearch 5.0中从TF/IDF更改为BM25

    从技术上讲,这实际上是一个变化,当移动到Lucene 6.2(默认的Elasticsearch 5.0.0)。

    Elasticsearch 5.0.0 Release Notes 包括以下行:

    #18948 (问题: #18944 )

    你可以阅读更多关于 Elasticsearch similarity here

    similarity 在要使用的映射文件中 classic

    description:
      type: text
      similarity: classic
    

    包含更多信息的有用链接:

    推荐文章