代码之家  ›  专栏  ›  技术社区  ›  Denisa Corbu

多场比赛不适用于分数不变的比赛

  •  1
  • Denisa Corbu  · 技术社区  · 6 年前

    我正在尝试禁用TF/IDF,使用constant_score进行多个匹配查询。

    GET cities/_search
    {
      "query": {
        "bool": {
          "must": [
            {
              "constant_score": {
                "query": {
                  "multi_match": {
                    "query": "new york",
                    "fields": [
                     "city",
                     "village"
                    ]
                  }
                }
              }
            }
          ]
        }
      }
    }
    

     "reason": "[constant_score] query does not support [query]".
    

    我也尝试过不使用查询包装器

    GET cities/_search
        {
          "query": {
            "bool": {
              "must": [
                {
                  "constant_score": {
                      "multi_match": {
                        "query": "new york",
                        "fields": [
                         "city",
                         "village"
                        ]
                      }
                  }
                }
              ]
            }
          }
        }
    

    但我得到了以下错误:

    "[constant_score] query does not support [multi_match]".
    

    是否有一个解决方法可以一起使用它们?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Hooman Bahreini    6 年前

    我不是弹性搜索的专家,而是阅读 this documentation

    constant_score 查询

    它在过滤器上下文中。所有匹配的文档都是相同的

    我相信你需要这样的东西:

    GET cities/_search
    {
      "query": {
        "constant_score": {
          "filter": {
            "multi_match": {
              "query": "new york",
              "fields": [
                "city",
                "village"
              ]
            }
          }
        }
      }
    }