【问题标题】:Caused by: org.elasticsearch.common.ParsingException: [bool] malformed query, expected [END_OBJECT] but found [FIELD_NAME]原因:org.elasticsearch.common.ParsingException:[bool] 格式错误的查询,应为 [END_OBJECT] 但找到 [FIELD_NAME]
【发布时间】:2017-11-04 19:47:04
【问题描述】:

原因:org.elasticsearch.common.ParsingException: [bool] 格式错误 查询,应为 [END_OBJECT],但找到了 [FIELD_NAME]

这是我的请求方式:

    {
      "bool": {
          "must": [
            {
                "range": {
                    "timestamp": {
                        "gt": ${timestamp_from},
                        "lt": ${timestamp_to},
                        "include_lower": true,
                        "include_upper": false
                    }
                }
            }
          ]
        },
      "aggs": {
        "max_timestamp": {
        "max": {
        "field": "timestamp"
        }
    }
  }
}

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    您的查询有几个问题,当您查看一些 ES 查询示例时很快就会发现这些问题。

    • 根键应该是query
    • aggs 键应该在 query 之后,而不是在 bool 之后
    • ES 不知道 ${timestamp_from}${timestamp_to} 是什么

    所以正确的查询可能是

    {
       "query": {
          "bool": {
              "must": [
                {
                    "range": {
                        "timestamp": {
                            "gt": 1409795880274,
                            "lt": 1509795880274,
                            "include_lower": true,
                            "include_upper": false
                        }
                    }
                }
              ]
            }
    },
          "aggs": {
            "max_timestamp": {
            "max": {
            "field": "timestamp"
            }
        }
      }
    }
    

    【讨论】:

    • 嗨,我使用了你的解决方案,但我遇到了和以前一样的问题。 PS:我的ES版本是5.6.3。我认为 ES 无法识别此查询的语法。非常感谢。
    • 我在使用你的查询时遇到了这个问题 [bool] 格式错误的查询,预期为 [END_OBJECT] 但找到了 [FIELD_NAME]
    • 请帮帮我先生
    猜你喜欢
    • 2018-02-10
    • 2022-01-14
    • 1970-01-01
    • 2018-04-25
    • 2021-04-22
    • 2020-02-26
    • 1970-01-01
    • 2018-01-30
    • 2022-10-25
    相关资源
    最近更新 更多