简体   繁体   English

Elasticsearch中的日期范围查询

[英]Date range query in elasticsearch

I want to fetch records from elasticsearch within a specific date range. 我想从特定日期范围内的elasticsearch中获取记录。 I have tried the following query- 我尝试了以下查询-

curl -X GET "http://localhost:9200/150/_search?pretty" -H "Content-Type:application/json" -d "{\"query\":{\"range\":{\"timestamp\":{\"gte\":\"16/Jan/2019\",\"lte\":\"18/Jan/2019\",\"boost\":2.0}}}}"

But here I am getting all the documents. 但是在这里,我得到了所有文件。 Can anyone please help me to solve this? 谁能帮我解决这个问题? Thank you in advance. 先感谢您。

You need to use the following date format: yyyy-MM-dd . 您需要使用以下日期格式: yyyy-MM-dd Try this instead: 尝试以下方法:

curl -X GET "http://localhost:9200/150/_search?pretty" -H "Content-Type:application/json" -d "{\"query\":{\"range\":{\"timestamp\":{\"gte\":\"2019-01-16\",\"lte\":\"2019-01-18\",\"boost\":2.0}}}}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM