How to search by date using elasticsearch


(nano) #1

Hello, i have some data stored in elasticsearch and what i want is to make an URL fix to search only for past 30 minutes data
for example i have a field named date
"Date" : "2017-04-04T23:42:40.081Z"
my goal is to return only data stored last 30 minutes
Thanks for help


(Jonathan Delfour) #2

something like that but haven't tested :slight_smile:

GET _search
{
    "query": {
        "range" : {
            "date" : {
                "gte" : "now-30m/m",
                "lt" :  "now/m"
            }
        }
    }
}

cf: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
and
https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math


(nano) #3

Thnak you for your reply there isn't way to have an url like 12.0.0.1:9200/some conditions ?


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.