# External Ruby, more than one value in a hash

**URL:** <https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434>\
**Category:** Logstash\
**Created:** [December 22, 2020, 10:39pm UTC](https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434 "2020-12-22T22:39:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [December 22, 2020, 10:39pm UTC](https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434/1 "2020-12-22T22:39:45Z")

</div>

I have been using this external ruby code to add data to the documents, when a document has a planet\_name equal to the key in the hash add the value to a field in the document

```auto
def register(params)
end
def filter(event)
planets= {
"jupiter" => "brown",
"mars" => "red",
};
 event.set('planets_char', planets[event.get('planet_name')])
return [event]
end

```

I was wondering If I could add more than one value and set it in a diferent field for each value. something like this:

```auto
planets= {
"jupiter" => ["brown", "big" , "colder"]
"mars" => ["red", "small", "cold"]
};

```

But I dont know how I can set different values to different fields.

whill this work? how can I set different values to different fields?

Thanks!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 22, 2020, 11:25pm UTC](https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434/2 "2020-12-22T23:25:23Z")

</div>

You appear to be implementing a [translate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html) filter. See [this](https://discuss.elastic.co/t/translate-filter-plugin/167971/2) thread for a way to add multiple fields.

---

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [December 23, 2020, 3:20am UTC](https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434/3 "2020-12-23T03:20:56Z")

</div>

Hi Badger, Then you think its not posible with ruby?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 23, 2020, 3:53pm UTC](https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434/4 "2020-12-23T15:53:13Z")

</div>

Anything is possible with ruby, you just need to write the code.

---

<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:** [January 20, 2021, 3:53pm UTC](https://discuss.elastic.co/t/external-ruby-more-than-one-value-in-a-hash/259434/5 "2021-01-20T15:53:26Z")

</div>

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