Last active
August 7, 2018 06:56
-
-
Save ZedYeung/330d4d5842c47a1c33815067dd0abaac to your computer and use it in GitHub Desktop.
This file contains hidden or 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 re | |
import glob | |
# https://www.elastic.co/blog/strings-are-dead-long-live-strings | |
files = glob.glob('./*19_mapping.json') | |
for file in files: | |
print(file) | |
with open(file) as f: | |
text = f.read() | |
text = re.sub(r'"type":(\s*)"string",(\s*)"index":(\s*)"not_analyzed"', | |
r'"type":"keyword","index":true', | |
text) | |
text = re.sub(r'"type":(\s*)"string",(\s*)"index":(\s*)"analyzed"', | |
r'"type":"text","index":true', | |
text) | |
with open(file, 'w') as f: | |
f.write(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment