1

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;
}

Also isFound() is deprecated, is there any alternative?

alok
  • 1,218
  • 1
  • 12
  • 29
Oussama EL ABED
  • 129
  • 1
  • 1
  • 10

0 Answers0