Skip to content

Instantly share code, notes, and snippets.

@graphaelli
Created September 24, 2018 15:17
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 graphaelli/a7536d528436cc3e5cfd2ec85ed846cf to your computer and use it in GitHub Desktop.
Save graphaelli/a7536d528436cc3e5cfd2ec85ed846cf to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
def dump(fields, pfx=None):
if pfx is None:
pfx = []
for field, attribs in sorted(fields.items()):
if 'properties' in attribs:
dump(attribs['properties'], pfx + [field])
if 'type' in attribs:
print(".".join(pfx + [field + ": " + attribs['type']]))
def main():
with open('tmpl.json') as f:
mappings = json.load(f)['mappings']['doc']['properties']
dump(mappings)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment