標籤:.com 返回 ges tty ota src 命令 href 文檔
擴充下,
Elasticsearch之curl刪除索引庫
[[email protected] elasticsearch-2.4.3]$ curl -XDELETE ‘http://192.168.80.200:9200/zhouls/emp/1‘
{"found":true,"_index":"zhouls","_type":"emp","_id":"1","_version":5,"_shards":{"total":2,"successful":1,"failed":0}}[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$ curl -XGET ‘http://192.168.80.200:9200/zhouls/emp/1?pretty‘
{
"_index" : "zhouls",
"_type" : "emp",
"_id" : "1",
"found" : false
}
[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$ curl -XDELETE ‘http://192.168.80.200:9200/zhouls/emp/1‘
{"found":false,"_index":"zhouls","_type":"emp","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$
[[email protected] elasticsearch-2.4.3]$ curl -XDELETE ‘http://192.168.80.200:9200/zhouls/emp/1‘
{"found":false,"_index":"zhouls","_type":"emp","_id":"1","_version":2,"_shards":{"total":2,"successful":1,"failed":0}}[[email protected] elasticsearch-2.4.3]$
es的機制,第一次刪除之後,在60秒之後,執行刪除命令,則version變為1,又開始增加了。(作為瞭解,不必感到驚訝)
ES的刪除操作補充知識
如果文檔存在,es會返回200 ok的狀態代碼,found屬性值為true,_version屬性的值+1。
如果文檔不存在,es會返回404 Not Found的狀態代碼,found屬性值為false,但是_version屬性的值依然會+1,這個就是內部管理的一部分,它保證了我們在多個節點間的不同操作的順序都被正確標記了。
注意:刪除一個文檔也不會立即生效,它只是被標記成已刪除。Elasticsearch將會在你之後添加更多索引的時候才會在後台進行刪除內容的清理。
ES刪除總結
ES的刪除操作,也是不會立即生效,跟更新操作類似。只是會被標記為已刪除狀態,ES後期會自動刪除。
好比,你刪除的操作一步一步累積,當達到它上限時,等你刪除幾十條資料後,ES我一次性刪除,這樣可以節省磁碟IO。
這些簡單的es刪除操作,容易的就在生產環境裡,手動輸入。複雜的,用java代碼去實現。
Elasticsearch之curl刪除