Scripted Field Referencing another Scripted Field (Array)


(Robert Slama) #1

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.


(Lukas Olson) #2

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.


(Robert Slama) #3

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


(system) #4

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