I am wondering about an alternative method to TermFilter()
in ES 7.5, it's deprecated since ES 2.x. My current method:
@Override
public boolean deleteAnnotation(String userName, String id) throws Exception {
final IndexAndType annotationIndex = indexConfiguration.getIndex(Annotation);
final SearchResponse searchResponse = esClient.prepareSearch(annotationIndex.getIndex()).setTypes(annotationIndex.getType()).setQuery(
filteredQuery(QueryBuilders.termQuery(AnnotationField.id.field(), id), termFilter(AnnotationField.user.field(), userName))
).execute().actionGet();
if (0 < searchResponse.getTotalShards()) {
final SearchHit hit = searchResponse.getHits().getAt(0);
final DeleteResponse deleteResponse = esClient.prepareDelete(annotationIndex.getIndex(), annotationIndex.getType(), hit.getId()).execute().actionGet();
return deleteResponse.isFound();
}
return false;
}