当我使用curl执行以下查询时
curl -XGET 'http://localhost:9200/logstash*/_search' -d '{ "query" : { "filter" : [ "range" : { "timestamp" : {"gt" : "2017-02-01 00:00:00","lt" : "2017-05-01 00:00:00"}}]}}'
我低于错误
{"error":{"root_cause":[{"type":"parsing_exception","reason":"[filter] query malformed, no start_object after query name","line":1,"col":26}],"type":"parsing_exception","reason":"[filter] query malformed, no start_object after query name","line":1,"col":26},"status":400}
但是,如果我使用Sense插件的上述查询执行日期范围过滤器,则运行良好。
flex 版本5.2
问候,
库纳尔
最佳答案
您只需要将查询更改为此:
curl -XGET 'http://localhost:9200/logstash*/_search' -d '{
"query": {
"bool": {
"filter": {
"range": {
"timestamp": {
"gt": "2017-02-01 00:00:00",
"lt": "2017-05-01 00:00:00"
}
}
}
}
}
}'
关于date - 无法在使用查询的 Elasticsearch 中实现日期范围过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43884942/