title: Finding two documents in MongoDB that share a key value
body: <p>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 <em>same name</em> and <em>different types</em>, a simple MongoDB counterpart of</p>
  
  <pre><code>SELECT ...
  FROM table AS t1, table AS t2
  WHERE t1.name = t2.name AND t1.type &lt;&gt; t2.type
  </code></pre>
  
  <p>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 documents. </p>