Elasticsearch constant_score不支持multi_match

时间:2017-02-08 12:29:32

标签: elasticsearch

我在Elasticsearch中有一个查询,我希望在多个字段上匹配以获得常量分数

"query": {
    "bool": {
      "must": [
        {
          "constant_score": {
            "multi_match": {
              "query": "e w h",
              "fields": [
                "displayterm.ngram",
                "citalias1.ngram",
                "citalias2.ngram"
              ],
              "type": "phrase_prefix"
            }
          }
        }
      ],

但是我收到以下错误:

  

" [constant_score]查询不支持[multi_match]",

1 个答案:

答案 0 :(得分:-2)

您需要将multi_match查询包装在query对象中:

{
  "query": {
    "bool": {
      "must": [
        {
          "constant_score": {
            "query": {
              "multi_match": {
                "query": "e w h",
                "fields": [
                  "displayterm.ngram",
                  "citalias1.ngram",
                  "citalias2.ngram"
                ],
                "type": "phrase_prefix"
              }
            }
          }
        }
      ]
    }
  }
}