Hello,
I'm having an issue with the range filter, here is the context :
I'm trying to do a simple query that filters on datetime field.
My document have a simple mapping :
"TRAITEMENT": {
"properties": {
"dat_cre_tra": {
"type": "date",
"format": "dd/MM/yyyy HH:mm:ss",
"locale": "fr"
},
"typ_tra": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
A sample document is inserted as this one :
{
"num_tra": "FLU0001_tra_0001",
"TRAITEMENT" : {
"dat_cre_tra": "08/10/2019 11:30:00",
"sta_tra": "E",
"ind_acq_tra": "N",
"typ_err": "4",
"typ_tra" : "RGP"
}
I'm trying to retrieve the "Traitements" that have a dat_cre_tra that littler than 15 minutes like this
{
"query" :{
"bool": {
"must": [
{
"range": {
"TRAITEMENT.dat_cre_tra": {
"gt" : "now-15y",
"lt" : "now+15m",
"time_zone": "+01:00"
}
}
}
]
}
}
}
but I didn't make it. So I started investigating and i started to query with different time units like this one :
{
"query" :{
"bool": {
"must": [
{
"range": {
"TRAITEMENT.dat_cre_tra": {
"gt" : "now-15y",
"lt" : "now+2h",
"time_zone": "+01:00"
}
}
}
]
}
}
}
This one works, the document is returned, whereas the same query with lt : now+1h does not work.
To resume, the document is only returned when the lt filter is bigger than 1h.
Am I missing something ?
Thanks for help