Can anyone help to see if this date range feature is available on an array or not? Any other alternative for this kind of search? Appreciate your help.
You may just have a typo, unless I'm misunderstanding what you're trying to do. With the example you gave, the airings both have a startTime of 2015-08-29 (at 10:00:00) and the query has startTime to be greater than or equal to 2015-08-30 (at 12:00:00). In the query, if you change startTime to be gte a time before a given startTime (2015-08-29 at 00:00:00, for example), the query works as expected:
In addition to the problem pointed out by Shane, your query will match match a document with a start time after the beginning of one airing and an end time before the end of a different airing. You could work around this by using nested objects and nested queries: https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-objects.html
Or you could denormalize and store a separate copy of the document for each airing (might give faster query performance this way).
Thank you Shane and David.
I am still not successful, my search result is returning data that is not in the requested range. Not sure, if my query is having issues. I have pasted here my query. and the result that i am getting.
Query:
Can you see if the title is making any difference here.
In this case, i requested for dates that match 8/30 and 8/31. Where as i got 8/5 and 9/2 dates.
Thanks a lot for your help
I believe you're running into the nested object issue that David was suggesting. By default, elasticsearch will flatten the data you send it. So your "airings" object won't maintain it's structure unless you explicitly tell elasticsearch that it's a nested object. So without setting up airings as type nested, it will treat your data as:
And when you query, startTime >= 2015-08-30 and endTime <= 2015-08-31, elasticsearch sees that the second element of the startTime array matches while the first element of the endTime array matches. Mapping airings as a nested type will maintain the structure. Alternatively, as David says, you could denormalize your data and store each entry as a airing document. There's a great blog post about managing object relationships like these which may help as well!
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.