Let's say I have a funds index with 2 documents like this
{
"fundId": 123,
"fundManager": {
"id": 123434,
"name": "Chris Inc"
},
"sectors": ["a", "b"]
}
{
"fundId": 456,
"fundManager": {
"id": 123434,
"name": "Chris Inc"
},
"sectors": ["c"]
}
Notice they are two different "funds" with the same fund manager.
What we want to do is retrieve all fund managers with the sectors they manage (e.g bring all the sectors together)
So in this case I'd want for the lack of a better word a "GROUP BY" and get something returned like
{
"fundManager": {
"id": 123434,
"name": "Chris Inc"
},
"sectors": ["a", "b", "c"]
}
Is this possible? How?
Let's put these documents into Elasticsearch and allowing ES to infer the types i.e. not setting up our own mapping.
There are 2 ways you can get all the sectors for a give fund manger: