I am using Elasticsearch 7.10 and want to delete a document inside an index using Delete By Query. I have referenced the official documentation on how to use the library but not sure what exactly i am missing. Any help is appreciated.
String indexName = "test_delete_index";
Map<String, String> testDoc = new HashMap<>();
testDoc.put("user", "abc");
testDoc.put("postDate", new Date().toString());
testDoc.put("message", "Test the Delete Method with Version");
testDoc.put("gender", "male");
DeleteByQueryRequest request = new DeleteByQueryRequest(indexName);
request.setConflicts("proceed");
request.setRefresh(true);
request.setQuery(new TermQueryBuilder ("gender","male"));
BulkByScrollResponse deleteResponse = client.deleteByQuery(request,RequestOptions.DEFAULT);
System.out.println("Delete By Query ::: " + deleteResponse.getDeleted());
The output says nothing got deleted :
Delete By Query ::: 0