Find and replace in elasticsearch all documents -
i wanted replace single username in elasticsearch index documents. there api query ?
i tried searching multiple couldn't find. 1 has idea?
my scenario:
curl -xpost 'http://localhost:9200/test/movies/' -d '{"user":"mad", "role":"tester"}' curl -xpost 'http://localhost:9200/test/movies/' -d '{"user":"bob", "role":"engineer"}' curl -xpost 'http://localhost:9200/test/movies/' -d '{"user":"cat", "role":"engineer"}' curl -xpost 'http://localhost:9200/test/movies/' -d '{"user":"bob", "role":"doctor"}'
i have above data in index called "test" , type "movies". here wanted replace "bob" name "alice".
thanks
update-by-query way go.
post /test/movies/_update_by_query { "script": { "inline": "ctx._source.user = 'alice'" }, "query": { "term": { "user": "bob" } } }
note: make sure enable dynamic scripting in order work.
Comments
Post a Comment