# How to create new bucket from various fields

**URL:** <https://discuss.elastic.co/t/how-to-create-new-bucket-from-various-fields/183689>\
**Category:** Kibana\
**Created:** [May 31, 2019, 9:09am UTC](https://discuss.elastic.co/t/how-to-create-new-bucket-from-various-fields/183689 "2019-05-31T09:09:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fim/32/90645_2.png) [@fim](https://discuss.elastic.co/u/fim)\
**Post date:** [May 31, 2019, 9:09am UTC](https://discuss.elastic.co/t/how-to-create-new-bucket-from-various-fields/183689/1 "2019-05-31T09:09:10Z")

</div>

I've an index with the following fields:

![image](https://us1.discourse-cdn.com/elastic/original/3X/e/d/ed7ce3bba4f31487b75d5ef6fe9428749d6440bf.png)

In these fields, search terms as text is stored.

In Kibana I would like to reach a histogram as follows:

y axis: number of search requests  
x axis: count of the four fields above

![image](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c7dfd298629d183d0acbd48ed4cf8a28f6c447b7.png)

How can I reach this?

---

<div class="post-metadata">

**Author:** ![christophilus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christophilus/32/42991_2.png) [@christophilus](https://discuss.elastic.co/u/christophilus)\
**Post date:** [June 4, 2019, 5:55pm UTC](https://discuss.elastic.co/t/how-to-create-new-bucket-from-various-fields/183689/2 "2019-06-04T17:55:35Z")

</div>

I _think_ I understand your scenario. It sounds like you have a field per language, and are filling that field in, so if I search in Chinese, it will be captured in the `ch` field of a document, but the other language fields (e.g. `en`) will be blank. Is that right? And you're basically trying to show a bar chart of the top languages used in your platform?

Is that right? If so, I wouldn't store each language as its own property. Instead, I'd create a `lang` property or something, and its value would be the language used (e.g. `"en"`). Then, creating your bar chart becomes a trivial terms operation.

---

<div class="post-metadata">

**Author:** ![fim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fim/32/90645_2.png) [@fim](https://discuss.elastic.co/u/fim)\
**Post date:** [June 5, 2019, 7:08am UTC](https://discuss.elastic.co/t/how-to-create-new-bucket-from-various-fields/183689/3 "2019-06-05T07:08:04Z")

</div>

Thanks Chris!  
You have understand the scenario correctly.

This means, the only way is to change the incoming data structure?

Is there an alternative way in Elasticsearch available without changing the incoming data structure? I mean to stay with your example, to create a kind of a bucket for these different language fields?

---

<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:** [July 3, 2019, 7:08am UTC](https://discuss.elastic.co/t/how-to-create-new-bucket-from-various-fields/183689/4 "2019-07-03T07:08:13Z")

</div>

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