简体   繁体   中英

elasticsearch bulk delete by custom field values

I'm building app with elasticsearch (5.4) and everything was going well until I try to delete several documents by field values. My x-ndjson looks like this:

{ "delete" : {} }
{ "id" : "109991" }
{ "delete" : {} }
{ "id" : "109992" }
{ "delete" : {} }
{ "id" : "109993" }
                        <- empty line

and i am POSTing it on http://localhost:9200/someindex/sometype/_bulk, but it responds with "Malformed action/metadata line [2], expected START_OBJECT or END_OBJECT but found [VALUE_NUMBER]" . Note that my "id" is my custom field, not the _id.

Is something missing in my request? Thank you

I guess you need to use Delete By Query for this.

POST index/_delete_by_query
{
   "query": {
    "terms": {
       "id": [
          109991,
          109992
       ]
    }
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM