MongoDB query against geospatial index with maxDistance fails from node.js client

Posted by user1735497 on Stack Overflow See other posts from Stack Overflow or by user1735497
Published on 2012-10-28T11:06:40Z Indexed on 2012/11/04 17:01 UTC
Read the original article Hit count: 238

I want to query against a geospatial index in mongo-db (designed after this tutorial http://www.mongodb.org/display/DOCS/Geospatial+Indexing).

So when I execute this from the shell everything works fine:

db.sellingpoints.find(( { location : { $near: [48.190120, 16.270895], $maxDistance: 7 / 111.2 } } );

but the same query from my nodejs application (using mongoskin or mongoose), won't return any results until i set the distance-value to a very high number (5690)

db.collection('sellingpoints')
 .find({ location: { $near: [lat,lng], $maxDistance: distance / 111.2} })
 .limit(limit)
 .toArray(callback);

Has someone any idea how to fix that?

© Stack Overflow or respective owner

Related posts about node.js

Related posts about mongodb