# How to Create Mapping to Aggregate on Strings in an Array

**URL:** <https://discuss.elastic.co/t/how-to-create-mapping-to-aggregate-on-strings-in-an-array/93677>\
**Category:** Elasticsearch\
**Created:** [July 19, 2017, 2:17am UTC](https://discuss.elastic.co/t/how-to-create-mapping-to-aggregate-on-strings-in-an-array/93677 "2017-07-19T02:17:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krmathieu](https://avatars.discourse-cdn.com/v4/letter/k/b5e925/32.png) [@krmathieu](https://discuss.elastic.co/u/krmathieu)\
**Post date:** [July 19, 2017, 2:17am UTC](https://discuss.elastic.co/t/how-to-create-mapping-to-aggregate-on-strings-in-an-array/93677/1 "2017-07-19T02:17:23Z")

</div>

I have the following JSON structure (on the top level of my docs) and my question is how do I set my mapping up so that I can aggregate on keyphrases.terms. I know I could recreate the data and create keyphrase objects consisting of the terms and the corresponding weights and use a nested query, but I am trying to avoid having to do that. Any help would be appreciated. Thanks.

Kevin

"keyphrases": {  
"terms": [  
"account",  
"account\_log",  
"birth\_niagara\_falls",  
"book\_download",  
"canadian\_football"  
],  
"weights": [  
1.0,  
1.0,  
1.0,  
1.0,  
1.0  
]  
}

---

<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:** [August 16, 2017, 2:17am UTC](https://discuss.elastic.co/t/how-to-create-mapping-to-aggregate-on-strings-in-an-array/93677/2 "2017-08-16T02:17:33Z")

</div>

Closed on August 16, 2017, 2:17am UTC

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