# Date range filter not returning match if doc\_values is false

**URL:** https://discuss.elastic.co/t/date-range-filter-not-returning-match-if-doc-values-is-false/281089
**Category:** Elasticsearch
**Created:** [August 11, 2021, 2:30pm UTC](https://discuss.elastic.co/t/date-range-filter-not-returning-match-if-doc-values-is-false/281089 "2021-08-11T14:30:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![AMAirfree](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@AMAirfree](https://discuss.elastic.co/u/AMAirfree)
#### Post date: [August 11, 2021, 2:30pm UTC](https://discuss.elastic.co/t/date-range-filter-not-returning-match-if-doc-values-is-false/281089/1 "2021-08-11T14:30:49Z")

</div>

Hello !

I've been confronted to a problem with one of my queries since upgrading my ElasticSearch version to 7.14.

I'm filtering nested objects containing a date property, it used to work correctly but ever since the upgrade, it seems to act as if the property does not exist.  
Putting doc\_values to true does fix the problem but it used to work without it. (and I set it to false voluntarily because I only needed it to filter, I don't need to retrieve the value)

Has something changed on this subject in recent versions which makes doc\_values mandatory for certain filters in nested objects ?

Even an "exist" filter returns nothing if the doc\_values is false in the mapping.

```auto
DELETE /testindex

PUT /testindex

PUT /testindex/_mapping
{
  "properties": {
    "son": {
      "type": "nested",
      "properties": {
        "date": {
          "type": "date",
          "doc_values": false
        }
      }
    }
  }
}

PUT /testindex/_doc/1
{
  "son": [
    {
      "date": "2021-08-11"
    }
  ]
}

GET /testindex/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "nested": {
            "path": "son",
            "query": {
              "bool": {
                "filter": [
                  {
                    "exists": {
                      "field": "son.date"
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

GET /testindex/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "nested": {
            "path": "son",
            "query": {
              "bool": {
                "filter": [
                  {
                    "range": {
                      "son.date": {
                        "gte": "2000-01-01"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

```

---

<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: [September 8, 2021, 2:31pm UTC](https://discuss.elastic.co/t/date-range-filter-not-returning-match-if-doc-values-is-false/281089/2 "2021-09-08T14:31:32Z")

</div>

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