简体   繁体   English

如何使用 Spring 数据 Elasticsearch 删除索引?

[英]How to delete index using Spring Data Elasticsearch?

I am trying to delete indices in Elasticseach instance by code instead of native query.我正在尝试通过代码而不是本机查询来删除 Elasticseach 实例中的索引。 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()' 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由于 Spring 数据 Elasticsearch 4.0 这是可能的

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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