Say we have:
curl -XPOST "http://localhost:9200/t/t/1" -d'
{
"hobbies" : ["a", "b"]
}'
I know I can do this to append to hobbies:
curl -XPOST "http://localhost:9200/t/t/1/_update" -d'
{
"script" : "ctx._source.hobbies += hobby",
"params" : {
"hobby" : "c"
}
}'
But how can I do it so if hobby isn't 'c' but is 'b', I won't end up with ["a", "b", "b"] for hobby? So it only appends "c" if "c" isn't a hobby already?