mongodb - Struggling to get ordered results from the last retrieved article, given array of elements to search in -


i have collections of objects structure this:

{     "_id" : objectid("5233a700bc7b9f31580a9de0"),     "id" : "3df7ce4cc2586c37607a8266093617da",     "published_at" : isodate("2013-09-13t23:59:59z"),     ...     "topic_id" : [         284,         9741     ],     ...     "date" : numberlong("1379116800055") } 

i'm trying use following query:

db.collection.find({"topic_id": { $in: [ 9723, 9953, 9558, 9982, 9833, 301, ... 9356, 9990, 9497, 9724] }, "date": { $gte: 1378944001000, $lte: 1378954799000 }, "_id": { $gt: objectid('523104ddbc7b9f023700193c') }}).sort({ "_id": 1 }).limit(1000) 

the above query uses topic_id, date index not keep order of returned results.

forcing use hint({_id:1}) makes results ordered, nscanned 1 million documents though limit(1000) specified.

what missing?


Comments

Popular posts from this blog

c# - Pausing a storyboard on TabItem mouse over -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -