update multiple docs with single query
--> similar to
UPDATE WHERE
in SQL
POST /{index name}/_update_by_query
{
"script" : {
"source" : "ctx._source.{field name}--"
},
"query" : {
"match_all" : {}
}
}
delete multiple docs with single query
--> similar to
DELETE WHERE
in SQL
DELETE /{index name}/_delete_by_query
{
"query" : {
"match_all" : {}
}
}
how to perform CRUD on many docs with a single query
POST /_bulk
<!-- action and meta data -->
{ "index" : { "_index" : [index name], "_id" : [doc id] }}
<!-- data -->
{ [field name] : [value], ... }
{ "create" : {"_index" : [index name], "_id" : [doc id] }}
{ [field name] : [value], ... }
POST /_bulk
{ "update" : { "_index" : [index name], "_id" : [doc id] }}
{ "doc" : { [field name] : [value] }}
{ "delete" : {"_index" : [index name], "_id" : [doc id] }}
POST /[index name]/_bulk
{"delete" : { "_id" : [doc id] }}
Content-Type header should be application/x-ndjson
Each line must end with newline character
failed action will not affect other actions