Created
September 24, 2018 15:17
-
-
Save graphaelli/a7536d528436cc3e5cfd2ec85ed846cf 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
#!/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