Scripted Field Painless

Good morning. I am having problems when generating a scripted field. The situation is as follows. Inside my index, I have "field1" and "field2", if "field1" = 0, "field2" does not exist, if "field1" = 1, "field2" contains an array of strings.

What I need, is to generate a scripted field that is equal to the array of strings of "field2", the problem is, that when "field1" goes from 1 to 0, "field2" disappears and the value of my scripted field becomes null.

Can you think of a solution for this situation?

Thank you very much.

A scripted field is evaluated at query time and is not persisted and do not change the document. If you need it to persist you probably need to set it in the document, e.g. using an ingest pipeline.

Ok, thanks for your answer.

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