Access array element after split processor

I'm trying to access array element after splitting a string into array using a 'split' processor in an ingest node pipeline?

I have a long string separated by slash ('/'). I only want to pass one substring to index, and dump the rest.

For example, I have a string "/aaa/bbb/ccc". I only want to index "ccc".

My current idea is to use split + set + remove, but I don't know how to access the array element after splitting.

It looks to me there has to be a solution. But I can't find it anywhere.

I've tried {{array}}[3], {{array[3]}}, {{array}[3]}, {{array}}.values[3], doc['array'].values[3]. None of them works.

Try using a script processor. Your script could look something like this (eg for the first element):

"script": "ctx._source['myfield'] = ctx._source['myfield'].split('/')[0]"

Thanks a lot, Ryan.

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