【发布时间】:2017-12-09 20:45:44
【问题描述】:
考虑以下从发送到 Elasticsearch 集群的请求返回的 JSON 数组:
[
{
"_type": "Event example",
"_source": {
"democarrier_s": "vodafone UK",
"m-Ecosystem_s": "iOS",
"demo-application": "demo",
"demo-country-code": "GB"
}
},
{
"_type": "Event example",
"_source": {
"democarrier_s": "Verizon",
"m-Ecosystem_s": "iOS",
"demo-application": "demo1",
"demo-country-code": "US"
}
}
]
我正在尝试找出如何在不重复和不硬编码任何值的情况下从该文档中获取所有唯一键,并将它们存储到以下形式的对象中:
columns = ['_type', '_source.democarrier_s', '_source.m-Ecosystem_s', '_source.demo-application', '_source.demo-country-code'];
有人可以帮我弄清楚如何实现这一目标吗?我一直在尝试遍历文档并存储密钥,但我无法弄清楚。 '_type' 可以硬编码到列对象中,因为它会一直存在。
提前感谢您的帮助和时间。
【问题讨论】:
标签: javascript arrays json elasticsearch