Elasticsearch之curl刪除

來源:互聯網
上載者:User

標籤:.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刪除

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.