Elasticsearch必须与mustnot结合使用,否则解析不会失败

时间:2018-09-07 11:37:14

标签: elasticsearch

有人知道如何解决以下查询吗?

400:{“错误”:{“ root_cause”:[{“ type”:“ parsing_exception”,“ reason”:“ [someField1]查询格式不正确,查询名称后没有start_object”,“ line”:6,” col“:22}],” type“:” parsing_exception“,” reason“:” [someField1]查询格式错误,查询名称后没有start_object“,” line“:6,” col“:22},”状态“: 400}

   {
      "query": {
        "bool": {
          "must": [
            {
              "someField1": true
            }
          ],
          "must_not": [
            {
              "exists": {
                "field": "someField2"
              }
            }
          ]
        }
      }
    }

1 个答案:

答案 0 :(得分:3)

您缺少对testField1的查询,它应该是termmatch

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {                   <--- add this 
             "someField1": true
          }
        }
      ],
      "must_not": [
        {
          "exists": {
            "field": "someField2"
          }
        }
      ]
    }
  }
}