Scripted Field Referencing another Scripted Field (Array)

I am new at this, and not sure if it is doable. I am trying to set an array, then validate a field value (whether its exists in my array) all in one, or 2 separate scripted field.
here is what I have, and what I am trying to do:

I have this and it works, but it feels redundant:
sc-test
if (
doc['somefield.keyword'].value =~ /valueA/ ||
doc['somefield.keyword'].value =~ /valueB/ ||
doc['somefield.keyword'].value =~ /valueC/
) {
return "invalid PN"
} else {
return "valid PN"
}

This is what I am looking to achieve:
sc-list
“ValueA,ValueB,ValueC”

sc-test
if (
doc['somefield.keyword'].value =~ doc['sc-list'].value
) {
return "invalid"
} else {
return "valid"
}

or plugin the array on the same sc-test:

list = [ValueA,ValueB,ValueC]

if (
doc['somefield.keyword'].value =~ list
) {
return "invalid"
} else {
return "valid"
}

ERROR: Courier Fetch: 5 of 5 shards failed.

Unfortunately, it's currently not possible to reference one scripted field from another scripted field. If you'd like to see this, feel free to add an enhancement request on Github.

How can I define an array in the same scripted field, then do the validation against it?

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