# How to merge two arrays into single array

**URL:** https://discuss.elastic.co/t/how-to-merge-two-arrays-into-single-array/247171
**Category:** Kibana
**Created:** [September 2, 2020, 5:57am UTC](https://discuss.elastic.co/t/how-to-merge-two-arrays-into-single-array/247171 "2020-09-02T05:57:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![developer\_apk](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@developer\_apk](https://discuss.elastic.co/u/developer_apk)
#### Post date: [September 2, 2020, 5:57am UTC](https://discuss.elastic.co/t/how-to-merge-two-arrays-into-single-array/247171/1 "2020-09-02T05:57:15Z")

</div>

How can i show values in kibana pie chart from multiple array fields ?

I have document like below:

```auto
{
  "field1": ["a", "b", "c"], 
  "field2": ["a", "x", "y", "z"],
}

```

I want to see the aggregations combining both fields like

```auto
{"field3": ["a", "b", "c", "x", "y", "z"]}

```

If there is no direct way in kibana, can i use painless script to create new field for existing documents ? can someone provide me, to use in update\_by\_query ?

---

<div class="post-metadata">

### Author: ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)
#### Post date: [September 14, 2020, 11:35am UTC](https://discuss.elastic.co/t/how-to-merge-two-arrays-into-single-array/247171/2 "2020-09-14T11:35:06Z")

</div>

What you have there is aggregated data by itself. This is not what Kibana's Pie Chart uses. It does requests on non-aggregated data to Elasticsearch which then returns aggregated data to display. For this you could probably look into Canvas as it also has Pie Charts and it can use single documents as a source for it.

---

<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: [October 12, 2020, 11:35am UTC](https://discuss.elastic.co/t/how-to-merge-two-arrays-into-single-array/247171/3 "2020-10-12T11:35:09Z")

</div>

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