I am trying to run an ingest pipeline to replace instances of "on" and off" to true and false in an array.
This works perfectly with normal strings eg with data like this
[{onoffboolean: "on"}]
I am able to process this with the following:
processors: [
{
set: {
field: 'onoffboolean',
description: 'String represented trues to native true',
if: "ctx?.onoffboolean == 'on'",
value: true
}
},
{
set: {
field: 'onoffboolean',
description: 'String represented falses to native true',
if: "ctx?.onoffboolean == 'off'",
value: false
}
},
],
However when its an array of values eg:
["on", "on", "off"] to process into [true, true, false]
I am unable to get the right processor to handle this. I have attempted to use foreach but it seems the "_ingest._value" is not available when using an "if" conditional.
This elastic forum thread suggests using a painless script instead
https://discuss.elastic.co/t/foreach-ingest-processor-conditional-append-processor/216884/2
However I don't have enough of an understanding of painless scripting to work this out.