1、Code -> GitHub
https://github.com/liufengji/elasticsearch_api.git
2、源代码
@Test
public void deleteIndex(){
// 1 删除索引
client.admin().indices().prepareDelete("blog2").get();
// 2 关闭连接
client.close();
}
3、查看结果
浏览器查看http://hadoop102:9200/blog2
没有blog2索引了。
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"blog2","index_uuid":"na","index":"blog2"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"blog2","index_uuid":"na","index":"blog2"},"status":404}