# Is there a way to substitute a string name for a key "value" in buckets of aggregation results

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-substitute-a-string-name-for-a-key-value-in-buckets-of-aggregation-results/87972>\
**Category:** Elasticsearch\
**Created:** [June 1, 2017, 7:21pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-substitute-a-string-name-for-a-key-value-in-buckets-of-aggregation-results/87972 "2017-06-01T19:21:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Steiner](https://avatars.discourse-cdn.com/v4/letter/d/90ced4/32.png) [@David\_Steiner](https://discuss.elastic.co/u/David_Steiner)\
**Post date:** [June 1, 2017, 7:21pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-substitute-a-string-name-for-a-key-value-in-buckets-of-aggregation-results/87972/1 "2017-06-01T19:21:07Z")

</div>

Here is the aggregation:  
"aggs" : {  
"bucketA" : {  
"terms" : { "field" : "field1" }  
}

Here is the results:  
"bucketA": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 0,  
"buckets": [  
{  
"key": "value1",  
"doc\_count": 667  
},  
{  
"key": "value2",  
"doc\_count": 328  
},  
{  
"key": "value3",  
"doc\_count": 1  
}  
]  
}

I want to have a file (I imagine store in Elasticsearch somewhere?) that contains the replacement values:

```
"value1" : "replacement1"
"value2" : "replacement2"
"value3" : "replacement3"

```

Is there a way to specify this in the "aggregation", or do I have to capture the result and do the substitution subsequently?

---

<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 29, 2017, 7:31pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-substitute-a-string-name-for-a-key-value-in-buckets-of-aggregation-results/87972/2 "2017-06-29T19:31:29Z")

</div>

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