# Using filters on nested fields

**URL:** <https://discuss.elastic.co/t/using-filters-on-nested-fields/73562>\
**Category:** Logstash\
**Created:** [February 1, 2017, 5:56pm UTC](https://discuss.elastic.co/t/using-filters-on-nested-fields/73562 "2017-02-01T17:56:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shambar](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@shambar](https://discuss.elastic.co/u/shambar)\
**Post date:** [February 1, 2017, 5:56pm UTC](https://discuss.elastic.co/t/using-filters-on-nested-fields/73562/1 "2017-02-01T17:56:53Z")

</div>

I am having an issue trying to get logstash to see the items in the array beyond the first item.

the data will come in like.

{"id": "430229930",  
"item\_tbl" :[{"itemid": 1,"itemname":"eggs","quantity": 10},{"itemid": 2,"itemname":"milk","quantity": 10}]}

I can access the first item in the array by referencing [item\_tbl][0][itemname]

I know the second item is [1] but how do I get logstash to mutate or manipulate all the items in the array?

the documents will vary on the number of items in the array.

I would like to use just basic filters like mutate on the fields.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 2, 2017, 6:51am UTC](https://discuss.elastic.co/t/using-filters-on-nested-fields/73562/2 "2017-02-02T06:51:38Z")

</div>

> I know the second item is [1] but how do I get logstash to mutate or manipulate all the items in the array?

That depends on the filter being used. Some support arrays and some don't. You may have to use a ruby filter to work around such limitations.

---

<div class="post-metadata">

**Author:** ![shambar](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@shambar](https://discuss.elastic.co/u/shambar)\
**Post date:** [February 2, 2017, 8:42pm UTC](https://discuss.elastic.co/t/using-filters-on-nested-fields/73562/3 "2017-02-02T20:42:38Z")

</div>

I would like to use the mutate filter and rename itemname to item\_name. I have not used ruby yet so there may be a bit of a learning curve for me to go that route.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 3, 2017, 6:32am UTC](https://discuss.elastic.co/t/using-filters-on-nested-fields/73562/4 "2017-02-03T06:32:12Z")

</div>

What you want to do will require use of the ruby filter.

---

<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:** [March 3, 2017, 6:32am UTC](https://discuss.elastic.co/t/using-filters-on-nested-fields/73562/5 "2017-03-03T06:32:23Z")

</div>

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