# Could not Perform aggregations :illegal\_argument\_exception

**URL:** https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792
**Category:** Elasticsearch
**Created:** [May 30, 2018, 5:38am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792 "2018-05-30T05:38:49Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Eswar\_123](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@Eswar\_123](https://discuss.elastic.co/u/Eswar_123)
#### Post date: [May 30, 2018, 5:38am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792/1 "2018-05-30T05:38:49Z")

</div>

I created an index megacorp. PUT 3 documents in it through kibana console.

eg..  
PUT /megacorp/employee/2  
{  
"first\_name" : "Jane",  
"last\_name" : "Smith",  
"age" : 32,  
"about" : "I like to collect rock albums",  
"interests": ["music"]  
}

when I try to perform aggregations by passing below request through kibana console..

```
GET megacorp/employee/_search
{
  "aggs": {
    "all_interests": {
      "terms": {
        "field": "interests"
      }
    }
  }
}

```

I am getting this error response..

```
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "megacorp",
        "node": "PTK-1g-dR-CV0KXVD5eMSQ",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
        }
      }
    ]
  },
  "status": 400
}

```

Could anyone help me with this....I followed elastic-search definitive guide(2.x) to do this...I am using elastic search 6.2.4 on Windows...

---

<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: [May 30, 2018, 6:00am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792/2 "2018-05-30T06:00:46Z")

</div>

run the agg on

```
interests.keyword
```

---

<div class="post-metadata">

### Author: ![Eswar\_123](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@Eswar\_123](https://discuss.elastic.co/u/Eswar_123)
#### Post date: [May 30, 2018, 6:14am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792/3 "2018-05-30T06:14:00Z")

</div>

Could you please post me editing my request...Couldn't understand exactly what you want me to change.

---

<div class="post-metadata">

### Author: ![Dvikas](https://avatars.discourse-cdn.com/v4/letter/d/a9adbd/32.png) [@Dvikas](https://discuss.elastic.co/u/Dvikas)
#### Post date: [May 30, 2018, 6:18am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792/4 "2018-05-30T06:18:51Z")

</div>

> [@Eswar\_123](#):
>
> "field": "interests"

"filed": "interests.keyword"

---

<div class="post-metadata">

### Author: ![Eswar\_123](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@Eswar\_123](https://discuss.elastic.co/u/Eswar_123)
#### Post date: [May 30, 2018, 6:21am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792/5 "2018-05-30T06:21:29Z")

</div>

Got it!..Thank you very much

---

<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: [June 27, 2018, 6:24am UTC](https://discuss.elastic.co/t/could-not-perform-aggregations-illegal-argument-exception/133792/6 "2018-06-27T06:24:42Z")

</div>

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