-2

I am using Spring-Data-Elasticsearch in my project, and I want to delete document by ElasticsearchRepository interface.

There is not a response from delete api, so I can't distinguish whether the document existed in ES.

I don't want to seperate into two steps by using exists() api.

Krzysztof Janiszewski
  • 3,763
  • 3
  • 18
  • 38

1 Answers1

0

https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#repositories.core-concepts

As you known there is nothing returned by the delete method so you have to use boolean existsById(ID primaryKey); first to know if it exists.

Elasticsearch is a very fast engine, so the cost is nothing, except if you want to delete a million documents.

Maelig
  • 2,046
  • 4
  • 24
  • 49