简体   繁体   中英

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()' 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.

Since Spring Data Elasticsearch 4.0 this is possible with

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM