How can I search on time ranges in Elasticsearch? -
i have lots of data looks this:
{ "timestamp": "2015-04-23t14:35:43.511z", "component1health": "false", "area": "squad1" } { "timestamp": "2015-04-23t18:03:22.911z", "component1health": "true", "area": "squad7" }
i want search on, say, instances of
"component1health": "false"
that occurred on weekday between 8am , 8pm.
the docs @ https://www.elastic.co/guide/en/elasticsearch/guide/current/_ranges.html show it's easy search on date ranges, eg
"range" : { "timestamp" : { "gt" : "2014-01-01 00:00:00", "lt" : "2014-01-07 00:00:00" } }
but can't work out i'm doing wrong extract time. i've been through stackoverflow , es forum etc can't crack it.
can help?
thanks, andy
i don't think can achieve date range. simple solution indexing new integer field contains hour of day. 2 documents like:
{ "timestamp": "2015-04-23t14:35:43.511z", "houroftheday": 14, "component1health": "false", "area": "squad1" } { "timestamp": "2015-04-23t18:03:22.911z", "houroftheday": 18, "component1health": "true", "area": "squad7" }
and can similar range filter on new field like:
"range" : { "houroftheday" : { "gt" : 7, "lt" : 21 } }
hope helps.
Comments
Post a Comment