Runtime field Create Nested Object


I'm trying to create a run-time field which creates an array. I've been doing simple things like creating strings based on a conditional field but I can't seem to get the right syntax for a multi-value string object. This is currently what I'm looking to do....

(this is done within Kibana)

if (doc['criteria.keyword'].value == 'condition') emit('result1','result2');

Expected result:

"test": [

The emit I've used below fires a syntax error about having more than one condition.

Thanks for the assistance.

Reading the signatures of the emit method in the documentation I don't think arrays are supported, but I may be wrong.

Hi @JeremyP , you can call emit() multiple times in your script in order to return a multi-valued field.

1 Like

Interesting. I think I did this but it did not work. Based on this I concluded that once there is a match, it no longer processes the other lines.

If you'd like further advice, please provide a reproducible test (for instance one request to index a document, and one search query with a runtime field)