I am using mongodump command to dump mongodb data, but when I am restoring it using mongorestore it changes order of documents (order in which documents was inserted), What might be the issue? Is there any way by which I can preserve insertion order?
Asked
Active
Viewed 906 times
4
-
http://stackoverflow.com/questions/11599069/how-does-mongodb-sort-records-when-no-sort-order-is-specified – ewcz Sep 13 '16 at 11:29
1 Answers
7
You can use "maintainInsertionOrder" to preserve the insertion order. The default is False.
--maintainInsertionOrder
Default: False
If specified, mongorestore inserts the documents in the order of their appearance in the input source, otherwise mongorestore may perform the insertions in an arbitrary order.

notionquest
- 37,595
- 6
- 111
- 105
-
1It is not working, actually, I have checked my dump records using "bsondump collection.bson > collection.json" and I found that this dump doesn't maintain insertion order. – Rushi Soni Sep 14 '16 at 04:38