【问题标题】:Elasticsearch must combined with mustnot fails parsingElasticsearch 必须结合 mustnot 解析失败
【发布时间】:2019-02-12 18:18:16
【问题描述】:

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

400: {"error":{"root_cause":[{"type":"parsing_exception","re​​ason":"[someField1] 查询格式错误,查询名称后没有 start_object","line":6," col":22}],"type":"parsing_exception","re​​ason":"[someField1] 查询格式错误,查询名称后没有 start_object","line":6,"col":22},"status": 400}

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

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您在testField1 上缺少一个查询,它应该是termmatch

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

    【讨论】:

    • 感谢万解决了这个问题。我会在 8 分钟后按接受
    • 酷,很高兴它有帮助!
    猜你喜欢
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    • 2018-04-29
    • 2018-04-06
    • 1970-01-01
    • 2020-03-15
    • 2014-08-17
    • 1970-01-01
    相关资源
    最近更新 更多