I had a field named 'tags' in my documents, which is of type array, how can I do this:
If a tag is in the field 'tags', then do nothing; else add the tag to 'tags'.
Forgive me that I have no idea with groovy, but I've tried this:
curl -XPOST localhost:9200/file/company/13862/_update?pretty -d '{script:{inline:"ctx._source.tags.contains(tag) ? ctx.op=\"noop\" : ctx._source.tags += tag", params: {tag: 3}}}'
But it turns out the error:
"Failed to compile inline script [ctx._source.tags.contains(tag) ? ctx.op=\"noop\" : ctx._source.tags += tag] using lang [groovy]"