Skip to content

Instantly share code, notes, and snippets.

@windhamwong
Created August 22, 2018 06:54
Show Gist options
  • Save windhamwong/bb8d4f3558e310db91a3385741671d3f to your computer and use it in GitHub Desktop.
Save windhamwong/bb8d4f3558e310db91a3385741671d3f to your computer and use it in GitHub Desktop.
Reference of update by query adding tag into doc
GET /<something>/_update_by_query?pretty
{
"query": {
"bool": {
"must_not": [
{
"match_phrase": {
"tags.keyword": {
"query": "parsed"
}
}
},
{
"match_phrase": {
"tags.keyword": {
"query": "unparsed"
}
}
}
]
}
},
"script": {
"source": "if (ctx._source.tags == null) { ctx._source.tags = [params.tag]}else{ctx._source.tags.add(params.tag)}",
"params": {
"tag": "unparsed"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment