I have a DATE field in an index with
"type" : "date" &
"format" : "strict_date_optional_time||epoch_millis"
I need to get all the Documents in a mentioned year(say : return all documents whose date field has year 2017)
I have a DATE field in an index with
"type" : "date" &
"format" : "strict_date_optional_time||epoch_millis"
I need to get all the Documents in a mentioned year(say : return all documents whose date field has year 2017)
Should be easy enough, what have you tried?
Its working in case of query string :
i) http://localhost:9200/_search?q=2017
But
when i am finding the same with the attibuteName , its returning null .Dont know why?
ii)http://localhost:9200/_search?q=mydateAttributeName:2017
I cant use i) , cause the any other field in the document can also have 2017 as text.
Is it possible to get it done using Query-DSL?
"range-query" did the job
To get the records in year 2017 using query-dsl ,
{
"query": {
"range": {
"myDateAttributeName": {
"gte": "2016-12-31T00:00:00.000Z",
"lte": "2018-01-01T00:00:00.000Z"
}
}
}
}
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.