Hi there!
I'd like to add an ingest pipeline to my index in order to add some further info to incoming documents.
Let's say these docs have two fields, USERNAME and CITY. I'd like to add also latitude and longitude according to the field city.
I tried with an ingest pipeline like the following:
PUT _ingest/pipeline/my_index
{
"processors": [
{
"script": {
"source": """
if (ctx.place == params.key_rome) {
ctx.lat = params.rome_lat;
ctx.long = params.rome_long;
}
if (ctx.place == params.key_ny) {
ctx.lat = params.ny_lat;
ctx.long = params.ny_long;
}
if (ctx.place == params.key_london) {
ctx.lat = params.london_lat;
ctx.long = params.london_long;
}
""",
"params": {
"key_rome": "Rome",
"rome_lat": "X",
"rome_long": "Y",
"key_ny": "NewYork",
"ny_lat": "Z",
"ny_long": "T",
"key_london": "London",
"london_lat": "V",
"london_long": "W"
}
}
}
]
}
It didn't give any error but it simply did nothing.
I also tried adding a useless line after the last 'if block' simply to copy the field "place" into another field ctx.new_place = ctx.place
and it didn't work either.
What am I doing wrong?
Thank you!