title: MongoDB - Count does not match number of documents
body: <p>I am trying to write a function that moves documents from collection_one to collection_two. I have run into an odd error where the counts don't add up.</p>
  
  <blockquote>
    <p>collection_one.count({}) return 3.3 mil records</p>
  </blockquote>
  
  <p>After moving all the documents, <code>collection_two.count({})</code> return 3.2 mil.</p>
  
  <p>Each document in <code>collection_one</code> contains a unique uuid <code>run_id</code>. When I run the following commands, these are the outputs:   </p>
  
  <blockquote>
    <p>collection_one.count({'run_id': { $eq : 'uuid'}}), I get 3.2 mil<br>
    collection_one.count({'run_id': { $ne : 'uuid'}}),  I get 0;</p>
  </blockquote>
  
  <p>Basically, there are 0.1 mil missing records, which only show up in the empty count.<br>
  I have tried moving the documents in a couple of different ways via pymongo and using copyTo() in the shell.</p>
  
  <pre><code>for doc in source.find():
      try:
          target.insert(doc)
      except:
          print('Did not copy')
  </code></pre>
  
  <p>and a batch move function</p>
  
  <pre><code>for n in range(0, ceil_num_of_batches):
      result = source.find(data_filter).limit(batch_size).skip(n*batch_size)
      insert_queries = [InsertOne(doc) for doc in result]
      try:
          target.bulk_write(insert_queries)
      except BulkWriteError as bwe:
          logger.error(bwe.details)
  </code></pre>
  
  <p>Both of these produce the same error. copyTo() however copies all 3.3 mil but has been deprecated.<br>
  Collection_two has a unique index but collection_one doesn't. </p>