I have a collection of documents structured like this. For instance:
{ 'observer': 'machine1',
'seen': [
{'page1': ['/link1', '/link3']},
{'page2': ['/link4', '/link1']},
}
{ 'observer': 'machine2',
'seen': [
{'page3': ['/link2']},
{'page1': ['/link5']},
}
I'm trying to get a list of all distinct keys and values in the array, grouped by observer. In an ideal world, it would look something like:
{'machine1': ['/link1', '/link3', '/link4'], 'machine2': ['/link2', '/link5'] }
and
{'machine1': ['page1', 'page2'], 'machine2': ['page1', 'page3']}
I understand that I can use $aggregate and $group to get unique values based on sublists, but I'm unsure how to deal with the lists of objects and grab their keys and values.