Elasticsearch中的Function_score,multi_match,script_score和filter

时间:2018-02-20 19:53:05

标签: elasticsearch

我在向现有的多匹配查询中添加过滤器时遇到了问题,该查询嵌入在function_score中。

理想情况下,我希望按"term" : { "lang" : "en" }进行过滤,只能获取使用英语的文档。

我尝试过移动订单,尝试将我的查询包装在bool中,但只是无法让过滤器与我正在使用的其他功能一起使用。

我的查询代码:

GET /my_index/_search/
{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "filter": {
            "term": {
              "lang": "en"
            }
          },
          "multi_match": {
            "query": "Sample Query here",
            "type": "most_fields",
            "fields": [
              "body",
              "title",
              "permalink",
              "name"
            ]
          }
        }
      },
      "script_score": {
        "script": {
          "source": "_score + 10"
        }
      }
    }
  }
}

错误代码:

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[bool] query does not support [multi_match]",
        "line": 11,
        "col": 19
      }
    ],
    "type": "parsing_exception",
    "reason": "[bool] query does not support [multi_match]",
    "line": 11,
    "col": 19
  },
  "status": 400
}

我使用的是最新版本的Elasticsearch(我相信6.2)

2 个答案:

答案 0 :(得分:1)

尝试将multi_match包装在像这样的必须条款中

"must": {
    "multi_match": ...
}

错误消息清晰,bool查询仅接受filtermustshould

答案 1 :(得分:0)

最终解决方案:

GL_TEXTURE0 + <an int value>
相关问题