Is it possible, using the Java API, to combine the two deletion requests? I try to do this:

DeleteByQueryRequestBuilder requestBuilder = new DeleteByQueryRequestBuilder(client.getClient(), DeleteByQueryAction.INSTANCE) .setQuery(QueryBuilders.boolQuery().must(matchQuery("leftId", leftId())).must(matchQuery("rightId", rightId()))) .setQuery(QueryBuilders.boolQuery().must(matchQuery("leftId", rightId())).must(matchQuery("rightId", leftId()))); requestBuilder.get(); 

But only one request is executed - the last request.

  • Use bulk request - etki
  • can you give an example please? - PREDATORik
  • one
    So, I didn’t immediately see the original request, even bulk is not needed here. You just have to wrap both queries in bool query with should. stackoverflow.com/questions/25552321/… - etki
  • one
    should is a little complicated OR, do "(leftId = right AND rightId = left) OR (leftId = left AND rightId = right)" - should(must(leftId = right, rightId = left), must(leftId = left, rightId = right)) - etki
  • one
    it is called several times, well, github.com/elastic/elasticsearch/blob/… - etki

1 answer 1

No, it is impossible, in the builder one request is frayed to another, because of this the last one is executed.