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定一個參數實現就可以了