首页   快速返回

elasticsearch5.0文档删除API     所属分类 elasticsearch
根据原文翻译整理
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/docs-delete.html



curl -XDELETE 'http://localhost:9200/twitter/tweet/1'

删除文档时可以指定版本 ,使用乐观锁机制, 做版本检查,确保删除时没有进行其他更新操作

在文档上执行的每个写操作(包括删除操作)都会导致其版本增加。

写入 删除 再写入 对于同一个ID 版本会一直递增

curl -X PUT http://127.0.0.1:9200/customer/type1/1?pretty -d '{"name":"tiger"}'
curl -X DELETE http://127.0.0.1:9200/customer/type1/1?pretty

http://127.0.0.1:9200/customer/type1/1?pretty

指定路由
routing=xxx

When the _routing mapping is set as required and no routing value is specified, 
the delete api will throw a RoutingMissingException and reject the request.

当_routing映射设置为必需且没有指定路由值时,将抛出 RoutingMissingException 。

The parent parameter can be set, which will basically be the same as setting the routing parameter.

通过设置 parent 来指定路由

删除父文档不会自动删除其子文档

删除给定父id的所有子文档的一种方法是使用Delete By查询API来执行一个带有自动生成(和索引的)字段_parent的索引,
该字段的格式为parent_type#parent_id。
删除子文档时,必须指定它的父文档id,否则抛出RoutingMissingException异常。

索引自动生成
The delete operation automatically creates an index if it has not been created before 

The delete operation gets hashed into a specific shard id. 
It then gets redirected into the primary shard within that id group, 
and replicated (if needed) to shard replicas within that id group.

删除操作重定向到主分片执行,然后应用到其他副本
相当于异步删除 


When making delete requests, you can set the wait_for_active_shards parameter 
to require a minimum number of shard copies to be active 
before starting to process the delete request. 

wait_for_active_shards 参数设置
Control when the changes made by this request are visible to search.
?refresh
加refresh参数,是删除对搜索可见


超时设置 
curl -XDELETE 'http://localhost:9200/twitter/tweet/1?timeout=5m'

上一篇     下一篇
elasticsearch5.0API约定

elasticsearch5.0文档索引API

elasticsearch5.0文档读取API

kafka这些年

elasticsearch5.0文档查询删除API

elasticsearch5.0文档更新API