External Ruby, more than one value in a hash

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

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:

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!

You appear to be implementing a translate filter. See this thread for a way to add multiple fields.

1 Like

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

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

1 Like

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