Array in Scripted Field

Hi @LeeDr

I saw a publication, the cula you explained how to work with array in a scripted field, I had a question, if I want to pivot in a table, an array so that in each cell a value of the array is assigned, how would I do it

I thank you in advance for your answer

1 Like

Hi Alejandra,

If I understand your question, if you have a field "colors" with values like ["green", "blue", "yellow"] (and other possible colors), I think you would have to create a scripted field for each color and check if that color is in the array, and if it is, return "true" or something like that. So you might have a scripted field for green, blue, yellow, red, orange.

For this doc, the green field would be true, the blue field would be true, the yellow field would be true, and the red and orange fields would be false. But if colors included "black" and you didn't have a scripted field for it, you wouldn't know.

Is that what you need?

We also have runtime fields, which are similar to scripted fields if you're on a recent version Runtime fields | Elasticsearch Guide [8.1] | Elastic

And we also have Transforms, which might be able to do this Tutorial: Transforming the eCommerce sample data | Elasticsearch Guide [8.1] | Elastic

Regards,
Lee

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