简体   繁体   English

elasticsearch批量删除自定义字段值

[英]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.我正在使用 elasticsearch (5.4) 构建应用程序并且一切顺利,直到我尝试按字段值删除多个文档。 My x-ndjson looks like this:我的 x-ndjson 看起来像这样:

{ "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]" .我在 http://localhost:9200/someindex/sometype/_bulk 上发布它,但它的响应是“格式错误的操作/元数据行 [2],预期为 START_OBJECT 或 END_OBJECT 但找到了 [VALUE_NUMBER]” Note that my "id" is my custom field, not the _id.请注意,我的“id”是我的自定义字段,而不是 _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
       ]
    }
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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