php - MongoDB document count fluctuation -


i facing issue document count in collection being erratic.

here workflow:

crawling first done scrapy. scraped items sent through pipeline , prepared writing collection using pymongo library.

next, perform check see if item exists (using key) , if so, inherit _id , use db.collection.save() achieve upsert. check done ensure fields exist before writing.

if item not exist, new document created in collection.

lastly, frontend php webpage allows users search documents in collection using php mongodb driver.

issue

i started noticing on webpage new documents appear in 1 crawl, disappear view suddenly, , mysteriously appear again after next crawl. went mongo shell , found specific query return fluctuating number of results if sent repeatedly. 1 , down 2 , stable number.

the thing don't @ no point in code remove() documents collection. impression db.collection.save() result in equal or increasing number of documents in collection.

is there form of blocking whereby documents being written cannot queried? or have crawling interval?

notes:

  • no indexing done on collection
  • each crawl+write process takes 5-10s , repeated in 30s interval.

code snippet of query:

    $cursor = $collection->find(array( '$or' => array(             array('post_content' => new mongoregex("/$safe/i")),             array('post_user' => new mongoregex("/^$safe$/i"))     )));     $cursor->sort(array('post_datetime' => -1)); 


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -