According to Mongo ODM one should be able to get distance after a near query:
When I use the near query as it shows in the documentation, I am able to get results however the distance never gets added.
Here is my query:
$query = $dm->createQueryBuilder('SomeBundle:Blah')
->select('id', 'name', 'distance', 'propertyType', 'squareFootage')->field('coordinates')->near($latitude, $longitude);
$results = $query->getQuery()->execute();
foreach ($results as $city) {
echo $city->name.': '.$city->distance."\n";
}
My distance property is set up as :
/** @MongoDB\Distance */
public $distance;
I get no results. Is there a bug with Mongo ODM?