I need to do some aggregations on a scripted term. The term will be calculated from a keyword field stored in my index.
The script will need to:
- Grab the first substring before a whitespace character
- Check it against a list/map of values and see if it matches any of them
- If it matches, rewrite the term to a new mapped value, otherwise keep the original
I'm wondering what the most efficient way to handle step 2 would be in a painless script. My initial thought was using a
Map<String,String>, but then I thought this might mean the map is discarded and created for every single document that gets passed through the script. Would it be more efficient to do a really big if-else stack? As much as I dislike this idea, performance will be important here, and this has to be done via script because the mappings might change over time.
Would really appreciate any insight on this - thanks for your help!