# Apply elastic plugin on array items

**URL:** https://discuss.elastic.co/t/apply-elastic-plugin-on-array-items/216445
**Category:** Logstash
**Created:** [January 24, 2020, 2:48pm UTC](https://discuss.elastic.co/t/apply-elastic-plugin-on-array-items/216445 "2020-01-24T14:48:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![parosio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/parosio/32/27367_2.png) [@parosio](https://discuss.elastic.co/u/parosio)
#### Post date: [January 24, 2020, 2:48pm UTC](https://discuss.elastic.co/t/apply-elastic-plugin-on-array-items/216445/1 "2020-01-24T14:48:35Z")

</div>

Hello,  
I need to apply a search/translate for a field which optionally contains multiple values:

```
  event_id;ext_ref; ... other fields
  "#123";"ref3"; . . . 
  "#244";"ref2|ref7"; . . .

```

the second field should be split (if it contains '|') and each of the resulting values looked up with elasticsearch plugin to enrich the event with additional fields.

The resulting doc should look like

```
  _id: "244",
  "_source": {
     "id": "244"
     "ext_ref" : ["ref2", "ref7"]
     "elk_fld1" : ["data for ref2", "data for ref7"]
     "elk_fld2" : ["more data for ref2", "more data for ref7"]
     . . .
 }

```

Is there any way to iterate over all the elements of ext\_ref, other than

```
if [ext_ref][0] { elasticsearch { . . . } }
if [ext_ref][1] { . . . }
 . . .
if [ext_ref][n] { . . . }

```

?

---

<div class="post-metadata">

### Author: ![Ramicoh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramicoh/32/61017_2.png) [@Ramicoh](https://discuss.elastic.co/u/Ramicoh)
#### Post date: [February 5, 2020, 2:15am UTC](https://discuss.elastic.co/t/apply-elastic-plugin-on-array-items/216445/2 "2020-02-05T02:15:18Z")

</div>

I guess you'll have to use the Ruby plugin and write Ruby code to iterate the collection...

---

<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 4, 2020, 2:15am UTC](https://discuss.elastic.co/t/apply-elastic-plugin-on-array-items/216445/3 "2020-03-04T02:15:21Z")

</div>

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