Skip to content

Instantly share code, notes, and snippets.

@ZedYeung
Last active August 7, 2018 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZedYeung/330d4d5842c47a1c33815067dd0abaac to your computer and use it in GitHub Desktop.
Save ZedYeung/330d4d5842c47a1c33815067dd0abaac to your computer and use it in GitHub Desktop.
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