I am trying to query one of my indexes for all records that have a date field (labels.expiresAt
) set gte
to now
. In other words, the date field should be later than today. That seems super straightforward, but when I set the range to "gte": "now"
I get 0 results and then I set it to "lte"
and the results show up. In the example result below, you can see that the expiresAt
value is 2023-06-03T17:31:50.000Z
which is 3 months from today so why would it show up in a search for dates lte
now? What am I doing wrong here? This seems incredibly unintuitive if it isn't a bug.
DSL Query:
GET /logs-*/_search
{
"query": {
"range": {
"labels.expiresAt": {
"gte": "now"
}
}
}
}
Hit that shows up but only if I set it to lte
instead of gte
:
{
"_index": "xxx",
"_id": "xxx",
"_score": 1,
"_source": {
"host": {
"hostname": "xxx"
},
"transaction": {
"id": "xxx"
},
"message": "Example",
"@timestamp": "2023-03-03T17:31:53.915Z",
"service": {
"name": "server"
},
"event": {
"dataset": "server.log"
},
"ecs": {
"version": "1.6.0"
},
"log.level": "info",
"process": {
"pid": 75
},
"labels": {
"expiresAt": "2023-06-03T17:31:50.000Z"
},
"environment": "development",
"trace": {
"id": "xxx"
},
"@version": "1",
"data_stream": {
"type": "logs",
"dataset": "generic",
"namespace": "default"
}
}
}