Let's say I have:
"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"
]
}
}
Each product has attributes. Each attribute has ID and a value. I can filter the products by attributes fine but for now I am creating the "possible attributes" list from MongoDB. I would like to find a way to generate such a list from ElasticSearch alone (and maybe just query MongoDB for additional data).
What I need is:
{
1: [a, z],
2: [b, c, y],
etc.
}
How would such a aggregation look like? Get all available attributes (grouped by attribute.id) with all of their possible values (throughout all products)?