# A question about aggregation of ElasticSearch 5.x

**URL:** https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802
**Category:** Elasticsearch
**Created:** [December 13, 2016, 2:08am UTC](https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802 "2016-12-13T02:08:53Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jintianlao](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jintianlao](https://discuss.elastic.co/u/jintianlao)
#### Post date: [December 13, 2016, 2:08am UTC](https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802/1 "2016-12-13T02:08:53Z")

</div>

Dear friends  
I have a question about ElasticSearch 5.x while I am studying.Now I had sucessfully inserted some data into my ElasticSearch server like this  
"  
PUT /megacorp/employee/3  
{  
"first\_name" : "Douglas",  
"last\_name" : "Fir",  
"age" : 35,  
"about": "I like to build cabinets",  
"interests": ["forestry"]  
}  
"

and I want to do some terms aggregation work like this  
"  
GET /megacorp/employee/\_search  
{  
"aggs" : {  
"last\_names" : {  
"terms" : { "field" : "last\_name" }  
}  
}  
}  
"  
but the server return some error infomation to me below  
"  
{  
"error": {  
"root\_cause": [  
{  
"type": "illegal\_argument\_exception",  
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [last\_name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."  
}  
],  
"type": "search\_phase\_execution\_exception",  
"reason": "all shards failed",  
"phase": "query",  
"grouped": true,  
"failed\_shards": [  
{  
"shard": 0,  
"index": "megacorp",  
"node": "kDADT13zSoSzS2ioRMiAlQ",  
"reason": {  
"type": "illegal\_argument\_exception",  
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [last\_name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."  
}  
}  
],  
"caused\_by": {  
"type": "illegal\_argument\_exception",  
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [last\_name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."  
}  
},  
"status": 400  
}  
"

Could you give some help to resolve it ? Thannk you.

---

<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: [December 13, 2016, 6:08am UTC](https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802/2 "2016-12-13T06:08:03Z")

</div>

Can you show us the current mapping?  
Probably using last\_name.keyword can work.

---

<div class="post-metadata">

### Author: ![jintianlao](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jintianlao](https://discuss.elastic.co/u/jintianlao)
#### Post date: [December 13, 2016, 6:27am UTC](https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802/4 "2016-12-13T06:27:44Z")

</div>

the current mapping below

{  
"megacorp": {  
"mappings": {  
"employee": {  
"properties": {  
"about": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"age": {  
"type": "long"  
},  
"aggs": {  
"properties": {  
"last\_names": {  
"properties": {  
"terms": {  
"properties": {  
"field": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
}  
}  
}  
}  
}  
}  
},  
"first\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"interests": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"last\_name": {  
"type": "text",  
"fields": {  
"keyword": {  
"type": "keyword",  
"ignore\_above": 256  
}  
}  
},  
"publisher": {  
"type": "text",  
"fielddata": true  
}  
}  
}  
}  
}  
}

---

<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: [December 13, 2016, 7:17am UTC](https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802/5 "2016-12-13T07:17:10Z")

</div>

So use the field I told you.

> [@dadoonet](#):
>
> Probably using last\_name.keyword can work.

---

<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: [January 10, 2017, 7:17am UTC](https://discuss.elastic.co/t/a-question-about-aggregation-of-elasticsearch-5-x/68802/6 "2017-01-10T07:17:33Z")

</div>

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