码迷,mamicode.com
首页 > Windows程序 > 详细

ElasticSearch(五) Delete API

时间:2017-12-26 18:05:57      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:ogr   UI   异步   instance   tin   str   .so   exce   查询条件   


一、根据查询结果删除(Delete By Query API)

BulkByScrollResponse response =
DeleteByQueryAction.INSTANCE.newRequestBuilder(client)   // transport client
.filter(QueryBuilders.matchQuery("gender", "male"))    //查询条件
.source("persons")    //索引名称
.get();

long deleted = response.getDeleted();    //已删除的文档数量
二、对查询结果异步删除

DeleteByQueryAction.INSTANCE.newRequestBuilder(client)
.filter(QueryBuilders.matchQuery("gender", "male"))
.source("persons")
.execute(new ActionListener<BulkByScrollResponse>() {
@Override
public void onResponse(BulkByScrollResponse response) {
long deleted = response.getDeleted();
}
@Override
public void onFailure(Exception e) {
// Handle the exception
}
});

ElasticSearch(五) Delete API

标签:ogr   UI   异步   instance   tin   str   .so   exce   查询条件   

原文地址:https://www.cnblogs.com/xiaocandou/p/8118551.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!