【发布时间】:2017-09-19 11:10:49
【问题描述】:
假设我有:
"hits": [
{
"_index": "products",
"_type": "product",
"_id": "599c2b3fc991ee0a597034fa",
"_score": 1,
"_source": {,
"attributes": {
"1": [
"a"
],
"2": [
"b",
"c"
],
"3": [
"d",
"e"
],
"4": [
"f",
"g"
],
"5": [
"h",
"i"
]
}
}
},
{
"_index": "products",
"_type": "product",
"_id": "599c4bb4b970c25976ced8bd",
"_score": 1,
"_source": {
"attributes": {
"1": [
"z"
],
"2": [
"y"
]
}
}
每个产品都有属性。每个属性都有 ID 和值。我可以很好地按属性过滤产品,但现在我正在从 MongoDB 创建“可能的属性”列表。我想找到一种方法来单独从 ElasticSearch 生成这样一个列表(也许只是查询 MongoDB 以获取其他数据)。
我需要的是:
{
1: [a, z],
2: [b, c, y],
etc.
}
这样的聚合会是什么样子?获取所有可用属性(按attribute.id 分组)及其所有可能值(在所有产品中)?
【问题讨论】:
标签: elasticsearch