# ElasticSearch query to perform aggregations against all fields in index

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-to-perform-aggregations-against-all-fields-in-index/77327>\
**Category:** Elasticsearch\
**Created:** [March 3, 2017, 3:06pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-perform-aggregations-against-all-fields-in-index/77327 "2017-03-03T15:06:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![annanyan](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@annanyan](https://discuss.elastic.co/u/annanyan)\
**Post date:** [March 3, 2017, 3:06pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-perform-aggregations-against-all-fields-in-index/77327/1 "2017-03-03T15:06:28Z")

</div>

We are using ElasticSearch 5.0.0.

Please find data in movies index in ElasticSearch in attachment.

![](https://us1.discourse-cdn.com/elastic/original/3X/5/d/5dab40f15b12660fed195c23ebaa5c21548bd13f.JPG)

Please let us know if there is a simpler query or any other way to perform the aggregation query given in snippet below on all the fields of index in mapping instead of just this single column.

```
GET /movies/_search?pretty
{
  "size": 0,
  "_source": false,
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "query": "*drama*"
    }
  },
  "aggs": {
    "distinct_tables_1": {
      "terms": {
        "field": "_type"
      },
      "aggs": {
        "distinct_col_1": {
          "terms": {
            "field": "genres.keyword",
            "include" : ".*rama.*"
          }
        }
      }
    }
  }
}
```

---

<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:** [March 31, 2017, 3:06pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-perform-aggregations-against-all-fields-in-index/77327/2 "2017-03-31T15:06:32Z")

</div>

Closed on March 31, 2017, 3:06pm UTC

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