# Terms aggregation on a keyword field returns no results

**URL:** https://discuss.elastic.co/t/terms-aggregation-on-a-keyword-field-returns-no-results/253436
**Category:** Elasticsearch
**Created:** [October 27, 2020, 12:29pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-a-keyword-field-returns-no-results/253436 "2020-10-27T12:29:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![akhilmathew001](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akhilmathew001/32/77941_2.png) [@akhilmathew001](https://discuss.elastic.co/u/akhilmathew001)
#### Post date: [October 27, 2020, 12:29pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-a-keyword-field-returns-no-results/253436/1 "2020-10-27T12:29:16Z")

</div>

I have Elastic search v7.2 with an index of 20 million documents.  
Part of es schema is as follows;

```auto
{
  "properties": {
    "industries_name": {
      "copy_to": [
        "keyword_search_copy_to_field"
      ],
    "type": "text",
    "fields": {
        "industries_name_keyword": {
          "eager_global_ordinals": true,
          "type": "keyword"
        }
      }
    }
  }
}

```

With this I am executing the following aggregation;

```auto
    {
       "aggs": {
        "industries": {
          "terms": {
            "field": "industries_name.industries_name_keyword",
            "size": 150
          }
        }
      },
      "from": 0,
      "size": 0
    }

```

Unfortunately, this query returns no aggregation buckets.

```auto
{
  "took": 79,
  "timed_out": false,
  "_shards": {
    "total": 6,
    "successful": 6,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 10000,
      "relation": "gte"
    },
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "industries": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    }
  }
}

```

What may be the reason?

NB: Data exist for the field

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 27, 2020, 2:52pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-a-keyword-field-returns-no-results/253436/2 "2020-10-27T14:52:09Z")

</div>

I can't see a reason.

Could you share a typical document you have indexed and the full mapping?

---

<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: [November 24, 2020, 2:52pm UTC](https://discuss.elastic.co/t/terms-aggregation-on-a-keyword-field-returns-no-results/253436/3 "2020-11-24T14:52:13Z")

</div>

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