Can't filter by date range when in updated stack

Hi everyone,
I'm new to elastic and I'm trying to migrate the ELK 5.8 to 7.11, but I'm having trouble on making the queries (also migrated) to work.
I've made some changes in the Indices (doping _type when mapping for example) but i can't get the filter by range working, it directly ignores the dates (not even errors shown) just not filtering at all. Take a look:
The document:

     {
        "_index" : "sai",
        "_type" : "_doc",
        "_id" : "vBRSGnoBY0NEERtxvbrP",
        "_score" : 1.0,
        "_source" : {
          "status" : "Emitido",
          "emission_date" : "2021-06-09T12:44:17Z",
          "procedureTime" : "",
          "_rev" : "1-4355953f0c76c52091c426c38c11d761",
          "number" : 1,
          "quota" : [
            "General"
          ],
          "active" : true,
          "user_by_procedure" : 1,
          "awaiting" : 0,
          "event" : {
            "date" : "2021-06-09T12:44:17Z",
            "doc_type" : "Event",
            "data" : {
              "section" : "Caja",
              "procedure" : "CAJA"
            },
            "name" : "Emitir"
          },
          "category" : "",
          "doc_type" : "Turn",
          "identifier" : "C1",
          "room" : "",
          "implementation" : "MATANZA_NORTE",
          "section" : "Caja",
          "priority" : 0,
          "room_await" : "Salon de Espera",
          "csrfmiddlewaretoken" : "FK1sSqWlWaNWPtt2dq8tqC9nFEnuaEUU",
          "procedure" : "CAJA"
        }

the mapping:

{
  "sai" : {
    "mappings" : {
      "event.date" : {
        "full_name" : "event.date",
        "mapping" : {
          "date" : {
            "type" : "date"
          }
        }
      }
    }
  }
}

The query (including an evident error in the date range that it is not recognized at all):

GET /sai/_search

{
  "query":{
    "bool": {
      "must": [
        {
          "match": {
          "implementation": "MATANZA_NORTE"
          }
        }
      ],
        "filter": [
        {
          "range": {
              "event.date": {
                  "gte": "01/06/2022",
                  "lte": "02/01/2021",
                  "format": "dd-MM-yyyy"
              }
          }
        }
      ]
    }
  }
}

Tried every date format you can imagine, and I've noticed that there was another kind of problem when nothing happened even if a messed up the date or the range like the example i am giving, all the documents are always coming back in the response.
This same query, with this same document, same mapping and almost the same index (_type removed) works fine in ES 5.8. So what am i doing wrong?
thank you all in advance.

please provide a fully reproducible example. Your mapping code does not work with a Elasticsearch 7.x version.

That will make debugging infinitely easier! Thanks! :slight_smile:

1 Like

I rewrote the query and solved the problem. don't knowing exactly how ahahaha.

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