Finding two documents in MongoDB that share a key value
问题 I have a large collection of documents in MongoDB, each one of those documents has a key called "name", and another key called "type". I would like to find two documents with the same name and different types , a simple MongoDB counterpart of SELECT ... FROM table AS t1, table AS t2 WHERE t1.name = t2.name AND t1.type <> t2.type I can imagine that one can do this using aggregation: however, the collection is very large, processing it will take time and I'm looking just for one pair of such