Issue with consecutive ElasticSearch Query with Java API

We have two different queries built using ElasticSearch Java API. First is update & second is delete on the same type of dicument. If the difference between firing the first & second query from user action is more than 20 sec then update & delete both working properly. But if after the update user delete it immediately the document is getting updated but not getting deleted.
From the logs we have checked the delete query is getting triggered properly and we are not getting any exception in java while deleting it from Java API.

Any help will be highly appreciated.

Elastic Search version : 2.1.1, Lucene Version : 5.3.1

Delete Query Java API :

DeleteByQueryResponse id = new DeleteByQueryRequestBuilder(esClient, DeleteByQueryAction.INSTANCE)
.setIndices(indexName)
.setTypes(type)
.setQuery(QueryBuilders.matchQuery("id", id))
.execute()
.actionGet();

It's because you are not waiting for the refresh to occur.
But running a delete by query in this case is super inefficient.

You'd better delete the document by its id:

DELETE index/_doc/id

https://www.elastic.co/guide/en/elasticsearch/client/java-api/2.1/java-docs-delete.html

Will this work here efficienty if use this.

Thanks for the response , yes we are not waiting for the refresh the previous event ; how to ensure this ? is there default waiting period which we can apply the query ? is there any other query API we need to use as per the ES version listed in the thread. Please provide detailed solution. Thanks

Yes. That's what I meant. Use that and you don't have to wait for a refresh and it's much more efficient.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.