比方说我有:
"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
)及其所有可能的值(在所有产品中)?