Skip to content

Filters aggregation does not return meta for date fields in range filter #28170

@ohadravid

Description

@ohadravid

Elasticsearch version (bin/elasticsearch --version): 6.1.1

Plugins installed: []

JVM version (java -version): From the official docker

OS version (uname -a if on a Unix-like system): Official docker, On docker for Mac

Description of the problem including expected versus actual behavior:
When using meta attr for aggregations, it should be returned by ES.
Since ES6, adding meta for filters aggregation when using a range filter on a date field does not return the meta (other filters and other field types seem to work).

Steps to reproduce:

  1. Add the document:
{
  "event_id": 1,
  "@timestamp": "2018-01-10T00:00:00.0000000Z"
}
  1. Run the query:
{
  "query": {
    "match_all": {}
  },
  "size": 0,
  "aggs": {
    "f90f4e": {
      "filters": {
        "filters": {
          "some_label": {
            "range": {
              "@timestamp": {
                "gte": "2016-12-01",
                "lte": "2017-02-01"
              }
            }
          }
        }
      },
      "meta": {
        "as_": "filters()"
      },
      "aggs": {
        "3018ae": {
          "cardinality": {'field': "event_id" }
        }
      }
    }
  }
}

And the result is:

{
    ...,
    "hits": {...},
    "aggregations": {
        "f90f4e": {
            "buckets": {
                "some_label": {
                    "doc_count": 1,
                    "3018ae": {
                        "value": 1
                    }
                }
            }
        }
    }
}

In ES5.6.3, the result is

{
    ...,
    "aggregations": {
        "f90f4e": {
            "meta": {
                "as_": "filters()"
            },
            "buckets": {
                "some_label": {
                    "doc_count": 0,
                    "3018ae": {
                        "value": 0
                    }
                }
            }
        }
    }
}

as expected.

Using anything but range, and range on a non-date field works.
Replacing @timestamp to event_id, gives the expected result as well.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions