Say I have the following documents:
{"_key": "1", "name": "George Washington"}
{"_key": "2", "name": "George Washington"}
{"_key": "3", "name": "John Adams"}
{"_key": "4", "name": "Thomas Jefferson"}
{"_key": "5", "name": "George Washington"}
{"_key": "6", "name": "Thomas Jefferson"}
I want to write an AQL statement that returns the keys of the document grouped by name, but only if the name occurs more than once.
So my desired output is:
[["1", "2", "5"], ["4", "6"]]
So far I have come up with
FOR doc IN documents
LET key = doc._key
COLLECT name = doc.name INTO groups KEEP key
RETURN (FOR g IN groups RETURN g["key"])
This returns:
[["1", "2", "5"], ["3"], ["4", "6"]]
How can I modify the AQL command to only get arrays with two or more entries?