具有空坐标的mongodb $ geonear

时间:2016-02-10 11:32:59

标签: mongodb

我想根据lat-long按$ geoNear距离获取数据。 问题是当坐标为空时,它不显示空条目的数据。

我的表结构如下所述: 表:CustomerTasks

{ 
"_id" : ObjectId("56b82d33435c892b786402fa"), 
"CreatedBy" : ObjectId("56b49e720a351d29b0daaee4"), 
"ModifiedBy" : ObjectId("56b49e720a351d29b0daaee4"), 
"ModifiedDate" : ISODate("2016-02-08T05:52:51.107+0000"), 
"TaskText" : "test3", 
"TaskDate" : ISODate("2016-02-11T05:54:50.152+0000"), 
"FromTime" : null, 
"ToTime" : null, 
"AvgSpendTime" : NumberInt(0), 
"MarketingTypeID" : ObjectId("000000000000000000000000"), 
"PromoCode" : null, 
"IsEnquiry" : false, 
"IsAppointment" : false, 
"AppointmentStatusID" : ObjectId("000000000000000000000000"), 
"Location" : null, 
"UserID" : ObjectId("56b49e720a351d29b0daaee4"), 
"IsDeleted" : false, 
"IsCompleted" : false, 
"CustomerSubTaskList" : null, 
"LocationID" : ObjectId("56b9cf531b6687e270432a7b"), 
"Coordinate" : [
    23.008451, 
    72.513027
]}


{ 
"_id" : ObjectId("56b84050435c881e00ed3aab"), 
"CreatedBy" : ObjectId("56b49e720a351d29b0daaee4"), 
"ModifiedBy" : ObjectId("56b49e720a351d29b0daaee4"), 
"ModifiedDate" : ISODate("2016-02-08T07:14:24.243+0000"), 
"TaskText" : "first", 
"TaskDate" : ISODate("2016-02-10T05:55:13.163+0000"), 
"FromTime" : null, 
"ToTime" : null, 
"AvgSpendTime" : NumberInt(0), 
"MarketingTypeID" : ObjectId("000000000000000000000000"), 
"PromoCode" : null, 
"IsEnquiry" : false, 
"IsAppointment" : false, 
"AppointmentStatusID" : ObjectId("000000000000000000000000"), 
"Location" : null, 
"UserID" : ObjectId("56b49e720a351d29b0daaee4"), 
"IsDeleted" : false, 
"IsCompleted" : false, 
"CustomerSubTaskList" : null, 
"LocationID" : ObjectId("000000000000000000000000")}

我的查询是: -

db.CustomerTasks.aggregate( [
{ $geoNear : { near: { type: 'Point', coordinates: [23.0063475,72.5065855] }, distanceField: "distance" ,spherical:true} },  

{ $sort: { "distance": 1 }}] ) 

所以,我无法获得不包含坐标的记录。

任何帮助将不胜感激。

0 个答案:

没有答案