大數據技術之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(); }
結果: