也能夠看我寫的下面的博客html
刪除,某一條數據,以下curl
[hadoop@master elasticsearch-2.4.0]$ curl -XDELETE http://master:9200/zhouls/user/1 {"found":true,"_index":"zhouls","_type":"user","_id":"1","_version":4,"_shards":{"total":2,"successful":2,"failed":0}}[hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$
獲得elasticsearch
若是咱們想要刪除的文檔存在,則found屬性值爲true,_version屬性的值+1。ide
若是咱們想要刪除的文檔不存在,found屬性值false,可是_version屬性的值依然會+1,這個就是內部管理的一部分,它保證了咱們在多個節點間的不一樣操做的順序都被正確標記了。oop
好比,以下,是咱們在上面已經刪除了的文檔,可見,它依然仍是+1。post
[hadoop@master elasticsearch-2.4.0]$ curl -XDELETE http://master:9200/zhouls/user/1 {"found":true,"_index":"zhouls","_type":"user","_id":"1","_version":4,"_shards":{"total":2,"successful":2,"failed":0}}[hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ curl -XDELETE http://master:9200/zhouls/user/1 {"found":false,"_index":"zhouls","_type":"user","_id":"1","_version":1,"_shards":{"total":2,"successful":2,"failed":0}}[hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ curl -XDELETE http://master:9200/zhouls/user/1 {"found":false,"_index":"zhouls","_type":"user","_id":"1","_version":2,"_shards":{"total":2,"successful":2,"failed":0}}[hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ curl -XDELETE http://master:9200/zhouls/user/1 {"found":false,"_index":"zhouls","_type":"user","_id":"1","_version":3,"_shards":{"total":2,"successful":2,"failed":0}}[hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$ curl -XDELETE http://master:9200/zhouls/user/1 {"found":false,"_index":"zhouls","_type":"user","_id":"1","_version":4,"_shards":{"total":2,"successful":2,"failed":0}}[hadoop@master elasticsearch-2.4.0]$ [hadoop@master elasticsearch-2.4.0]$
注意:刪除一個文檔不會當即生效,它只是被標記成已刪除。es將會在你以後添加更多索引的時候纔會在後臺進行刪除內容的清理。ui
官網url
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html