Skip to content

Support for $maxDistance #85

Closed
tjlytle opened this Issue Dec 8, 2012 · 3 comments

2 participants

@tjlytle
tjlytle commented Dec 8, 2012

I may be missing this, but there doesn't seem to be support for using $maxDistance with a $near query.

From the Mongo Docs:

db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } ).limit(20)
@tjlytle
tjlytle commented Dec 8, 2012

Looks like I missed it in the query builder object, as I expected to see it in the expression object. Digging through more of the code to understand why.

@jmikola jmikola added a commit that closed this issue Dec 8, 2012
@jmikola jmikola Support $maxDistance on $near query field criteria
Since maxDistance() was already used for the geoNear option with the same name, the method is overloaded based on whether geoNear() has already been called. Fixes #85.
59f73cd
@jmikola jmikola closed this in 59f73cd Dec 8, 2012
@jmikola
Doctrine member
jmikola commented Dec 8, 2012

@tjlytle: You were correct. The maxDistance() method you saw was for the geoNear command's option. There wasn't a method on the expression class to set $maxDistance for a find query's criteria. I just added the method and modified the Builder::maxDistance() to set either depending on whether geoNear() was called (i.e. the query type is Query::TYPE_GEO_LOCATION).

Thanks for bringing this up.

@tjlytle
tjlytle commented Dec 8, 2012

Thanks for the quick fix.

@tjlytle tjlytle added a commit to tjlytle/mongodb that referenced this issue Dec 8, 2012
@jmikola jmikola Support $maxDistance on $near query field criteria
Since maxDistance() was already used for the geoNear option with the same name, the method is overloaded based on whether geoNear() has already been called. Fixes #85.
5688651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.