如何在ElasticSearch DeleteByQuery java API中添加查询字符串参数?

时间:2018-05-02 03:56:58

标签: elasticsearch elasticsearch-plugin elasticsearch-java-api

我正在使用Elasticsearch版本2.3.1

我已经安装了deletebyquery插件来删除文件,并使用java API删除。

这是我的java api请求

DeleteByQueryRequestBuilder deleteRequest = DeleteByQueryRequestBuilder(esType, DeleteByQueryAction.INSTANCE)
        .setIndices(index)
        .setTypes(type);
deleteRequest.setQuery(boolQuery);
DeleteByQueryResponse resp = deleteRequest.get();

我的问题是,如何在java中的Deletebyquery查询请求中添加查询字符串参数,如大小,路由? doc(https://www.elastic.co/guide/en/elasticsearch/plugins/2.3/delete-by-query-usage.html)中提到了这些参数,但不知道如何添加java api!

1 个答案:

答案 0 :(得分:1)

您可以使用:

deleteRequest.setRouting(routing) // to set routing
deleteRequest.request().size(size) // to set the size