title: Aggregate duplicate documents with values in array in Mongo
body: <p>I have a large collection of documents that look as follows:</p>
  <pre class="lang-json prettyprint-override"><code>{ &quot;_id&quot;: &quot;5a760191813a54000b8475f1&quot;, &quot;orders&quot;: [{ &quot;row&quot;: &quot;3&quot;, &quot;seat&quot;: &quot;11&quot; }, { &quot;row&quot;: &quot;3&quot;, &quot;seat&quot;: &quot;12&quot; }], &quot;product_id&quot;: &quot;5a7628bedbcc42000aa7f614&quot; },
  { &quot;_id&quot;: &quot;5a75f6f17abe45000a3ba05e&quot;, &quot;orders&quot;: [{ &quot;row&quot;: &quot;3&quot;, &quot;seat&quot;: &quot;12&quot; }, { &quot;row&quot;: &quot;3&quot;, &quot;seat&quot;: &quot;13&quot; }], &quot;product_id&quot;: &quot;5a7628bedbcc42000aa7f614&quot; },
  { &quot;_id&quot;: &quot;5a75ebdf813a54000b8475e7&quot;, &quot;orders&quot;: [{ &quot;row&quot;: &quot;5&quot;, &quot;seat&quot;: &quot;16&quot; }, { &quot;row&quot;: &quot;5&quot;, &quot;seat&quot;: &quot;15&quot; }], &quot;product_id&quot;: &quot;5a75f711dbcc42000c459efc&quot; }
  </code></pre>
  <p>I need to be able to find any documents where the <code>product_id</code> and items in the <code>orders</code> array are duplicates. I can't quite seem to wrap my head around accomplishing this. Any pointers?</p>