marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

Add Geo support in SearchBuilder.cfc #8

Open marcesher opened 13 years ago

marcesher commented 13 years ago

Mongo Supports lightweight geospatial searching, described here: http://www.mongodb.org/display/DOCS/Geospatial+Indexing

I've added an ensureGeoIndex function into Mongo.cfc for creating the indexes, and you can currently use cfmongodb. to perform geo queries like so:

nearResult = mongo.query( collection ).add( "LOC", {"$near" = [38,-85]} ).search(limit=10);

But this is not idiomatic CFMongoDB and I'd like to add functions in SearchBuilder for building up the handful of geo queries.

I'm thinking something like:

mongo.query(coll).$near(field, min, max);

mongo.query(coll).$near(field, min, max, maxDistance);

we'd want support for $within, both "box" and "center", which would probably translate into

withinBox(..) and withinCenter(...)

Anything else?