Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch query based on timestamp

This is my elasticsearch query that intends to filter data between 11 pm and 12 pm on the day 2015.08.04. But it doesn't filter and gives many errors.

"query" : {"range" :
            {"@timestamp" :
              {"gt" : "2015-08-04  11:00:00", "lt" : "2015-08-04 12:00:00"} 
            } 
          }  
like image 358
Pooja Avatar asked Sep 16 '15 22:09

Pooja


People also ask

What is range query in Elasticsearch?

Range Queries in Elasticsearch Combining the greater than ( gt ) and less than ( lt ) range parameters is an effective way to search for documents that contain a certain field value within a range where you know the upper and lower bounds. In this example, we can find all cars that were made in 2016, 2017, and 2018: 1.

Should VS must Elasticsearch?

must means: Clauses that must match for the document to be included. should means: If these clauses match, they increase the _score ; otherwise, they have no effect. They are simply used to refine the relevance score for each document.


1 Answers

It works with the following query

{
   "query":{
      "range":{
         "@timestamp":{
            "gte":"2015-08-04T11:00:00",
            "lt":"2015-08-04T12:00:00"
         }
      }
   }
}
like image 147
Pooja Avatar answered Sep 28 '22 05:09

Pooja