Hello, for each collection mongodb will create a default unique index based on _id, then I create another unique index on two fields of the collection, i.e. {country_code : 1 , creation_time : -1}, if I search the docs in collections, I would like to have data returned sorted by creation_time in DESC, but from the test result I found it is not always the expected: sometimes it returns in DESC, sometimes no. From the stackoverflow I found something like :
"What if an index is used?
If an index is used, documents will be returned in the order they are found (which does necessarily match insertion order or I/O order). If more than one index is used then the order depends internally on which index first identified the document during the de-duplication process."
so my question is, how can I make the index of {country_code : 1 , creation_time : -1} firstly be used when I search the data?
thanks,
James