2014-02-08 62 views
0

这是我的聚集:

query = [ 
    {'$match' : { 'location' : { 
     '$geoWithin': {'$center' : [ [lng,lat], distance ] }} }} 
] 
dumps(DB.venue.aggregate(query)) 

但是它抛出:

OperationFailure: command SON([('aggregate', u'venue'), ('pipeline', 
[{'$match': {'location': {'$geoWithin': {'$center': [[u'23.729310', u'37.983716'], 
0.0023544184586407157]}}}}])]) failed: exception: Malformed geo query: { $geoWithin: 
{ $center: [ [ "23.729310", "37.983716" ], 0.002354418458640716 ] } } 

我也试图与$within代替$geoWithin$centerSphere,而不是$center但没有。 find()查询通常在内部和中心(docs)内工作。

这是一个错误,或只是不支持pymongo?由于java驱动程序与$geoWithin$centerSphere正常工作。第一

回答

4

第一件事,正确的查询是:

{'$match' : {'location' : {'$geoWithin': {'$centerSphere': [[lng,lat], distance] }} }}, 

然而,LNG和LAT以上,我是路过不浮动,但unicode字符,这样扔了错误。