Skip to content

Instantly share code, notes, and snippets.

@benwbrum
Created June 5, 2013 17:14
Show Gist options
  • Select an option

  • Save benwbrum/5715560 to your computer and use it in GitHub Desktop.

Select an option

Save benwbrum/5715560 to your computer and use it in GitHub Desktop.
Output of a query that appears to ignore $orderby
> db.search_records.find( { "$query" : { "primary_names" : { "$elemMatch" : { "first_name" : "william", "last_name" : "smith" } } }, $orderby: { "search_date" : 1 } }, {search_date:1})
{ "_id" : ObjectId("519bbef6a020dd26fd00370f"), "search_date" : "1846-10-14" }
{ "_id" : ObjectId("51aaa56aa020dd1e05005656"), "search_date" : "1679-12-28" }
{ "_id" : ObjectId("51aaa56aa020dd1e0500565a"), "search_date" : "1680-01-01" }
{ "_id" : ObjectId("51aaa52ca020dd1e05002904"), "search_date" : "1738-07-25" }
{ "_id" : ObjectId("51aaa50da020dd1e050010bc"), "search_date" : "1743-02-27" }
{ "_id" : ObjectId("51aaa530a020dd1e05002c96"), "search_date" : "1758-06-14" }
{ "_id" : ObjectId("51aaa504a020dd1e050009f2"), "search_date" : "1768-01-07" }
{ "_id" : ObjectId("51aaa573a020dd1e05005da3"), "search_date" : "1791-08-01" }
{ "_id" : ObjectId("51aaa542a020dd1e05003b98"), "search_date" : "1795-11-21" }
{ "_id" : ObjectId("51aaa508a020dd1e05000cdc"), "search_date" : "1804-12-03" }
{ "_id" : ObjectId("51aaa505a020dd1e05000b08"), "search_date" : "1810-11-03" }
{ "_id" : ObjectId("519bbed9a020dd26fd0020d9"), "search_date" : "1829-10-15" }
{ "_id" : ObjectId("519bbee1a020dd26fd00274d"), "search_date" : "1840-04-20" }
{ "_id" : ObjectId("519bbee9a020dd26fd002d5b"), "search_date" : "1842-10-25" }
{ "_id" : ObjectId("519bbeeaa020dd26fd002dc3"), "search_date" : "1842-12-26" }
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment