-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geo queries fails with maxDistance #24
Comments
What engine are you seeing this on: Adobe CF? Railo? Please submit a self-contained example that clearly demonstrates the issue. Thanks! |
Hi! i'm on Railo 3.3, here's an example code:
mongoConfig = createObject('component','com.cfmongodb.core.MongoConfig').init(dbName="db");
mongo = createObject('component','com.cfmongodb.core.Mongo').init(mongoConfig);
mongoCollection = mongo.getDBCollection("collection");
queryParams = {
criteria={},
skip=10,
limit=1000
};
queryParams.criteria['Position']['$nearSphere'] = [45.46427, 9.18951];
queryParams.criteria['Position']['$maxDistance'] = 0.00391972405142678; // (25 km / 6378 km)
query = mongoCollection.find(criteria=queryParams.criteria,skip=queryParams.skip,limit=queryParams.limit);
writeDump(query.asArray());
Cause: com.mongodb.MongoException the case sensitiveness is intentional in mongodb: https://jira.mongodb.org/browse/SERVER-4696 |
Thanks for the details. Your problem had the feel of Railo about it, which is why I asked. Railo has an arg to StructNew which should tell it to create an ordered struct: http://wiki.getrailo.org/wiki/FUNCTION:STRUCTNEW So for your queryParams, try this: criteria = structNew("linked"); If that doesn't work, try creating the entire queryParams struct as a linked struct Let me know if that fixes it |
Hi, unfortunatelly the linked structnew didn't solved the issue. by the way, i've done a little research about that and i've managed to solve the issue by the creation of a LinkedHashMap: queryParams = createObject("java", "java.util.LinkedHashMap") |
On Sun, Mar 4, 2012 at 12:04 PM, jdaury
You can also use cfmongodb's "newDBObject()" function to get an ordered map: mongoUtil.newDBObject().append( key, value ).append( key, value ); This will give you full type safety in addition to ordered keys
|
Geoqueries like $near and $nearSphere often fails if $maxDistance is specified, returning the following error:
-- geo values have to be numbers: { $maxDistance: 0.00391972405142678, $nearSphere: [ 45.46427, 9.18951 ] }
this geo query is order sentisive and maxDistance should not precede nearSphere
the following query returns the correct results
'Position' : { $nearSphere: [ 45.46427, 9.18951 ] ,$maxDistance: 0.00391972405142678}
The text was updated successfully, but these errors were encountered: