# How to list the array type field

**URL:** <https://discuss.elastic.co/t/how-to-list-the-array-type-field/120308>\
**Category:** Kibana\
**Created:** [February 17, 2018, 1:41pm UTC](https://discuss.elastic.co/t/how-to-list-the-array-type-field/120308 "2018-02-17T13:41:44Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [February 23, 2018, 3:19pm UTC](https://discuss.elastic.co/t/how-to-list-the-array-type-field/120308/4 "2018-02-23T15:19:22Z")

</div>

I created this data by posted this in the Dev Tools \> Console;

```auto
POST discuss/test
{
  "array":[0,1,2,3]
}
POST discuss/test
{
  "array":[0,3,2,9]
}

```

Then I created an index pattern for that data.

Discover shows this data;

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

I can create a Data Table visualization that shows the count of each of the values like this;

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a0444f9542b0dbf502180595dce025fec7430db2.png)

If I change the default Count metric to Sum of the array I get this. It took me a while to figure out what it was showing. For each row of the array, its showing the total sum of the arrays that contain that number. So `0` is in both arrays so it's showing the sum of both arrays. `9` is only in one array and the sum in that array is 14.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/9/f99344814089ca111ae91251923f2497c8ccc766.png)

I found an interesting article here; [https://www.compose.com/articles/how-to-script-painless-ly-in-elasticsearch/](https://www.compose.com/articles/how-to-script-painless-ly-in-elasticsearch/)

That shows that you can create a scripted field that can do things with the values in an array.

So I copied some code from that doc for `Painless Loops` and just changed the name of the field to create this scripted field for the index;

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

Now in Discover we see that scripted field `array_sum` has the sum of the array, which you could then use in visualizations instead of trying to use the array itself;

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

---

_[View the full topic](https://discuss.elastic.co/t/how-to-list-the-array-type-field/120308)._
