windows elasticsearch 清理歷史索引數據


1、首先保證windows環境中有curl工具,若沒有請下載:https://curl.haxx.se/windows/

2、查看自己的es索引情況,瀏覽器可以直接輸入:localhost:9200/_cat/indices?v 查看,當然也可以用命令curl "localhost:9200/_cat/indices?v"查看

  ps:更多命令參閱https://www.cnblogs.com/pilihaotian/p/5830754.html

3、執行刪除索引curl --user elastic:yourpwd -XDELETE "http://127.0.0.1:9200/prod-events-v1-2020.10.02",此命令類似於Drop Table

4、若是要刪除模糊刪除可以用*通配符替代,例如:curl --user elastic:yourpwd -XDELETE "http://127.0.0.1:9200/prod-events-v1-2020.10.*" 代表刪除整個十月份的索引

5、還一種方式:curl --user elastic:yourpwd -X POST -H "Content-Type:application/json" "http://127.0.0.1:9200/prod-events-v1-2020.09.09/_delete_by_query" -d "{\"query\":{\"range\":{\"@timestamp\":{\"lt\":\"now-10d\",\"format\":\"epoch_millis\"}}}}"  但實際未成功,可能是參數不是最新版本的,同時刪除效率會很慢,相當於delete from

6、至於定時清理,簡單一點,bat定一個參數實現就可以了

 


免責聲明!

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



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