Hi,
I want to create a query that returns all the data from last 3 days and only between 09:00 AM - 18:00 PM.
My date field contains both the date and the time of the day (For example "time" : "2019-08-06T06:40:55Z").
Can I do something like or how can I achieve this with this mapping (Elastic version 5.6)?
the fastest solution in terms of speed would be to have a bool with three should clauses, where each of them represents a range query filtering for each day. You could also use scripting and extract the hours of the day of a date and compare those, but that would end up in a massive speed reduction as each hit needs to be checked.
Please take your time and read through the documentation how must and should work together, as they change their behaviour, if there are no must clauses (something that is needed in order to model an OR query).
Thanks, I think ill go with the script since I don't think should will be good if I want larger date ranges than 3 days, and my query need to be generic and work with different range of dates and different range of time (Hours and Minutes).
you just take the minute into account as well, then you can model sth like 9:30. The date is always stored as UTC, you need to calculate offsets yourself.
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.