Date range filter not returning match if doc_values is false

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.

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"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

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