Details
-
Question
-
Resolution: Done
-
Major - P3
-
None
-
3.0.4
-
None
Description
data in db follows:
{ "_id" : ObjectId("55a8c1ba3996c909184d7a22"), "uid" : "1db82e8a-2038-4818-b805-76a46ba62639", "createdate" : ISODate("2015-07-17T08:50:02.892Z"), "palce" : "aa", "sex" : 1, "longdis" : 1, "location" : [ 106.607312, 29.575281 ] }
|
{ "_id" : ObjectId("55a8c1ba3996c909184d7a24"), "uid" : "1db82e8a-2038-4818-b805-76a46ba62639", "createdate" : ISODate("2015-07-17T08:50:02.920Z"), "palce" : "bbb", "sex" : 1, "longdis" : 1, "location" : [ 106.589896, 29.545098 ] }
|
{ "_id" : ObjectId("55a8c1ba3996c909184d7a25"), "uid" : "1db82e8a-2038-4818-b805-76a46ba62639", "createdate" : ISODate("2015-07-17T08:50:02.922Z"), "palce" : "ccc", "sex" : 1, "longdis" : 1, "location" : [ 106.590758, 29.566713 ] }
|
{ "_id" : ObjectId("55a8c1ba3996c909184d7a26"), "uid" : "1db82e8a-2038-4818-b805-76a46ba62639", "createdate" : ISODate("2015-07-17T08:50:02.923Z"), "palce" : "ddd", "sex" : 1, "longdis" : 1, "location" : [ 106.637039, 29.561436 ] }
|
{ "_id" : ObjectId("55a8c1bc3996c909184d7a27"), "uid" : "1db82e8a-2038-4818-b805-76a46ba62639", "createdate" : ISODate("2015-07-17T08:50:04.499Z"), "palce" : "eee", "sex" : 1, "longdis" : 1, "location" : [ 106.539522, 29.57929 ] }
|
{ "_id" : ObjectId("55a8d12e78292fa3837ebae4"), "uid" : "1db82e8a-2038-4818-b805-76a46ba62639", "createdate" : ISODate("2015-07-17T09:55:58.947Z"), "palce" : "fff", "sex" : 1, "longdis" : 1, "location" : [ 106.637039, 29.561436 ] }
|
I want to first of all, sort by the distance, if the distance is the same, sort by the time.
my command :
db.runCommand( { geoNear: "paging", near: [106.606033,29.575897 ], spherical : true,maxDistance : 1/6371, minDistance:0/6371,distanceMultiplier: 6371,num:2,query: {'_id': {'$nin': []}} })
|
or
db.paging.find({'location':{$nearSphere: [106.606033,29.575897], $maxDistance:1}}).limit(5).skip((2 - 1) * 2).sort({createdate:-1})
|
Which two commands can not meet the requirements, how to solve this problem, please?