Created
July 16, 2015 09:57
-
-
Save mishak87/11d22ff37c0c835b2c05 to your computer and use it in GitHub Desktop.
Generates CSV bool matrix with true where type has field from ElasticSearch /storage/_mappings
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
var x = /* elastic mapping */ {}; | |
var mappings = x.storage.mappings; | |
var map = {}; | |
for (var i in mappings) { | |
var k = Object.keys(mappings[i].properties); | |
for (l = 0; l < k.length; l++) { | |
map[k[l]] = {}; | |
} | |
} | |
for (var i in mappings) { | |
var k = Object.keys(mappings[i].properties); | |
for (l = 0; l < k.length; l++) { | |
map[k[l]][i] = true; | |
} | |
} | |
var types = Object.keys(mappings); | |
types.sort(); | |
var lines = [types]; | |
lines[0].unshift(''); | |
lines[0] = lines[0].implode(','); | |
for (var field in map) { | |
var r = [field]; | |
for (i = 0; i < types.length; i++) { | |
r.push(types[i] in map[field] ? 'TRUE' : 'FALSE'); | |
} | |
lines.push(r.implode(',')); | |
} | |
lines.implode("\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment