我想使用Java客户端从es删除一些文档,例如
curl -X POST "localhost:9200/twitter/tweet/_delete_by_query?conflicts=proceed" -H 'Content-Type: application/json' -d'
{
"query": {
"match_all": {}
}
}
'
BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client)
.filter(QueryBuilders.matchQuery("gender", "male"))
.source("persons")
.get();
long deleted = response.getDeleted();
看来您不能limit _delete_by_query to a single type
答案 0 :(得分:0)
您总是可以这样:
QueryBuilder query = QueryBuilders.boolQuery()
.filter(QueryBuilders.termQuery("_type", "tweet"))
.filter(QueryBuilders.matchQuery("gender", "male"));
BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client)
.filter(query)
.source("persons")
.get();
long deleted = response.getDeleted();