Created
January 13, 2016 17:40
-
-
Save tomachalek/b595cc7622b157fa8a1a to your computer and use it in GitHub Desktop.
transform prev. version of logs in ES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import json | |
import hashlib | |
def process_item(item): | |
rec = item['_source'] | |
rec['isQuery'] = rec.pop('entryQuery') | |
if rec.get('action', None) in ('wsketch', 'thes', 'wsdiff'): | |
rec['isQuery'] = True | |
rec['queryType'] = None | |
item['_id'] = hashlib.sha1(json.dumps(rec)).hexdigest() | |
item['_source'] = rec | |
def process(f): | |
for line in f: | |
d = json.loads(line) | |
process_item(d) | |
print(d) | |
if __name__ == '__main__': | |
with open(sys.argv[1], 'rb') as f: | |
process(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment