ElasticSearch之定时删除数据
来源:互联网 发布:中企动力域名管理 编辑:程序博客网 时间:2024/05/21 21:46
原链接
http://blog.csdn.net/shan1369678/article/details/51352350
有的时候我们在使用ES时,由于资源有限或业务需求,我们只想保存最近一段时间的数据,所以有如下脚本可以定时删除数据
delete_es_by_day.sh
- #!/bin/sh
- # example: sh delete_es_by_day.sh logstash-kettle-log logsdate 30
- index_name=$1
- daycolumn=$2
- savedays=$3
- format_day=$4
- if [ ! -n "$savedays" ]; then
- echo "the args is not right,please input again...."
- exit 1
- fi
- if [ ! -n "$format_day" ]; then
- format_day='%Y%m%d'
- fi
- sevendayago=`date -d "-${savedays} day " +${format_day}`
- curl -XDELETE "10.130.3.102:9200/${index_name}/_query?pretty" -d "
- {
- "query": {
- "filtered": {
- "filter": {
- "bool": {
- "must": {
- "range": {
- "${daycolumn}": {
- "from": null,
- "to": ${sevendayago},
- "include_lower": true,
- "include_upper": true
- }
- }
- }
- }
- }
- }
- }
- }"
- echo "ok"
注解:脚本传入参数说明:1.索引名;2.日期字段名;3.保留最近几天数据,单位天;4.日期格式,可不输(默认形式20160101)
0 0
- ElasticSearch之定时删除数据
- ElasticSearch之定时删除数据
- 定时拉取ElasticSearch数据
- elasticsearch删除数据
- elasticsearch批量删除数据
- elasticsearch之删除索引
- elasticsearch之删除文档
- elasticsearch根据条件删除数据
- elasticsearch删除index和数据
- (七)ElasticSearch删除数据
- Elasticsearch 之 数据索引
- ElasticSearch之数据索引
- 分布式搜索elasticsearch java API 之(三)(四)------索引数据、删除索引数据
- MySQL定时任务删除数据
- Elasticsearch(四)【Elasticsearch.Net之Post数据】
- Elasticsearch with Search-Guard定时删除旧索引
- 分布式搜索elasticsearch java API 之(四)------删除索引数据
- 分布式搜索elasticsearch java API 之(四)------删除索引数据
- stm8 Slave
- 【27.34%】【codeforces 611D】New Year and Ancient Prophecy
- NodeJS基础(二)——fs文件模块
- java 排序
- bzoj 2657: [Zjoi2012]旅游(journey) (map建图+树的直径)
- ElasticSearch之定时删除数据
- qduoj 农场主良辰(感谢cqupt...
- 【C#】C#中遍历文件夹下的目录文件
- 重载和重写的编码区别及JVM编译区别
- Android Studio中使应用全屏无标题的方法(老方法好像不能用了)
- 226. Invert Binary Tree
- Ubuntu Linux 安装 .7z 解压和压缩文件
- 关于log4j Properties放在不同路径下的问题
- Ionic简单接触:Windows下Ionic Android开发环境搭建