Home > Software design >  How to delete index using Spring Data Elasticsearch?
How to delete index using Spring Data Elasticsearch?

Time:02-18

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.

CodePudding user response:

Since Spring Data Elasticsearch 4.0 this is possible with

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