# Can't filter by date range when in updated stack

**URL:** <https://discuss.elastic.co/t/cant-filter-by-date-range-when-in-updated-stack/276301>\
**Category:** Elasticsearch\
**Created:** [June 17, 2021, 6:28pm UTC](https://discuss.elastic.co/t/cant-filter-by-date-range-when-in-updated-stack/276301 "2021-06-17T18:28:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caraboy](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@caraboy](https://discuss.elastic.co/u/caraboy)\
**Post date:** [June 17, 2021, 6:28pm UTC](https://discuss.elastic.co/t/cant-filter-by-date-range-when-in-updated-stack/276301/1 "2021-06-17T18:28:08Z")

</div>

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:

```auto
     {
        "_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:

```auto
{
  "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):

```auto
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.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 21, 2021, 9:12am UTC](https://discuss.elastic.co/t/cant-filter-by-date-range-when-in-updated-stack/276301/2 "2021-06-21T09:12:37Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![caraboy](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@caraboy](https://discuss.elastic.co/u/caraboy)\
**Post date:** [June 24, 2021, 12:52pm UTC](https://discuss.elastic.co/t/cant-filter-by-date-range-when-in-updated-stack/276301/3 "2021-06-24T12:52:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 22, 2021, 12:52pm UTC](https://discuss.elastic.co/t/cant-filter-by-date-range-when-in-updated-stack/276301/4 "2021-07-22T12:52:59Z")

</div>

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