title: $group in Mogoose Random Results But No Duplicate in Pagination
body: <p>Actually i want to produce random results each time page loads, it's working but on pagination sometimes I got
  duplicate results one or two products, am i doing something wrong. i am randomising by spliting product_code. your
  help is really appreciated.</p>
  <pre><code>var obj = {
    $or: [
      {
        'main_data.product_name': {
          $regex: req.body.searchTerm,
          $options: 'i'
        }
      },
      {
        'main_data.product_code': {
          $regex: req.body.searchTerm,
          $options: 'i'
        }
      }
    ],
  'main_data.status': 'active',
  }
  
  var query = [
  { $unwind: '$main_material' },
  {
    $project: {
      product_name: 1,
      product_code: 1,
      main_material: 1,
      status:1,
      qty_per_box:1,
      city_state: { $split: [&quot;$product_code&quot;, &quot;-&quot;] },
      qty: 1
    }
  },
  {
    $project: {
      product_name: 1,
      product_code: 1,
      main_material: 1,
      status:1,
      qty_per_box:1,
      city_state: &quot;$city_state&quot;
    }
  },
  { $group: { _id: { &quot;pc&quot;: &quot;$city_state&quot; }, main_data: { &quot;$first&quot;: &quot;$$ROOT&quot; }, cdate: { &quot;$first&quot;: &quot;$createdOn&quot; } } }, 
  { $match: obj}, 
  { $sort: { &quot;price_usd&quot;: 1 } },
  { $skip: parseInt(req.params.skip) },
  { $limit: parseInt(req.body.items) },
  ]  
  Products_model.aggregate(query);
  
  My Exact requirement is to show random products every time. But due to random list in
  pagination it creates duplicity in the results.
  </code></pre>