Elasticsearch-Java API操作(一)API基本操作(4)【刪除索引】


大數據技術之Elasticsearch-Java API操作(一)API基本操作

刪除索引

1)源代碼

@Test

public void deleteIndex(){

// 1 刪除索引

client.admin().indices().prepareDelete("blog2").get();

// 2 關閉連接

client.close();

}

2)查看結果

瀏覽器查看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}

********自己操作********

Java代碼:

@Test public void deleteIndex() { client.admin().indices().prepareDelete("blog").get(); // 關掉連接
 client.close(); }

結果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM