0

Elasticsearch version: 5.1.1

OS version: centos 7

Description of the problem including expected versus actual behavior: ES 5.1 version does not support delete-by-query plugin. so i need to change the javaAPI code.

The following code is from the previous 2.3 version.

    new DeleteByQueryRequestBuilder(ElasticConnector.getInstance().getJavaClient(), DeleteByQueryAction.INSTANCE) 
.setIndices(GLOBAL_ID) 
    .setTypes(MessageService.DEVICE) 
    .setQuery(QueryBuilders.boolQuery().should(QueryBuilders.termQuery("user_id", user_id)) 
    .should(QueryBuilders.termQuery("device_id", device_id) 
    .mustNot(QueryBuilders.boolQuery()
    .must(QueryBuilders.termQuery("user_id", user_id)) 
    .must(QueryBuilders.termQuery("device_id", device_id)) ))
    .execute().actionGet();

This code has a problem with

DeleteByQueryRequestBuilder cannot be resolved to a type

How do I change?

Jaap
  • 81,064
  • 34
  • 182
  • 193
염경훈
  • 27
  • 1
  • 7

1 Answers1

0

I think this can solve your problem

BulkIndexByScrollResponse response =
  DeleteByQueryAction.INSTANCE
    .newRequestBuilder(ESClient)
    .filter(yourQuery)
    .source(your index)
    .get();

regards