andrew17
andrew17

Reputation: 925

How to delete index using Spring Data Elasticsearch?

I am trying to delete indices in Elasticseach instance by code instead of native query. So I want to do this request:

DELETE /index-name

  public void deleteFoo(){
    DeleteRequest deleteRequest = new DeleteRequest("Foo");
    Request delete = RequestConverters.delete(deleteRequest);
    elasticsearchTemplate.delete(delete);
  }

But I get exception org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'org.elasticsearch.core.TimeValue org.elasticsearch.action.delete.DeleteRequest.timeout()'

What I am doing wrong?

I try to delete it by name, but would be nice to be able to delete all indices by one query.

Upvotes: 1

Views: 3102

Answers (1)

Abacus
Abacus

Reputation: 19461

Since Spring Data Elasticsearch 4.0 this is possible with

elasticsearchTemplate.indexOps(IndexCoordinates.of("indexname")).delete();

Upvotes: 3

Related Questions