1

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.

1 Answer 1

3

Since Spring Data Elasticsearch 4.0 this is possible with

elasticsearchTemplate.indexOps(IndexCoordinates.of("indexname")).delete();
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, already found it. Forgot to answer by myself, my bad :)
As of version 4.0 Spring Data ElasticsearchTemplate is deprecated and ElasticsearchRestTemplate should be used instead link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.