Skip to content

Instantly share code, notes, and snippets.

@mishak87
Created July 16, 2015 09:57
Show Gist options
  • Save mishak87/11d22ff37c0c835b2c05 to your computer and use it in GitHub Desktop.
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
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