ES以更新时间为标准,分离数据
首先声明……因各种原因无法使用python安装es模块,所以使用一种笨方法进行数据删除……
ES数据备份、迁移、导入可查看链接:https://www.cnblogs.com/Huang-Niu/p/12598643.html
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Create Time : 2020/4/1 @File Name : elasticsearch_del.py @Author : Mr.yang @Python Version : 2.7 @Software : PyCharm """ import time import json Time = '2020-03-01 00:00:00' jsonfile = open('./备份出来的的索引.json', 'r') file = open('./时间大于Time的.json', 'w') nonefile = open('./无更新时间戳的.json', 'w') nullfile = open('./更新时间戳为null的.json', 'w') def timestamp(times): if not times is None: timems = float(times/1000) time_local = time.localtime(timems) dt = time.strftime("%Y-%m-%d %H:%M:%S", time_local) if dt >= Time: g = json.dumps(line) file.write(g) else: d = json.dumps(line) nullfile.write(d) for line in jsonfile: line = json.loads(line) s = line['_source'] if s.has_key('updateTime'): timestamp(s['updateTime']) else: n = json.dumps(line) nonefile.write(n)
原创文章,转载请注明:
转载自蜡笔没小新博客
————————————
https://www.cnblogs.com/Huang-Niu/