I use geoNear()to calculate distances between objects in my Mongo database. The query works fine, even with input field filters such as ->field('name')->equals($name)etc.
This automatically fills the displayed @ODM \ Distance field on the object.
$this->getQueryBuilder()
->geoNear((float) $query['near_longitude'], (float) $query['near_latitude'])
->spherical(true)
->distanceMultiplier(self::EARTH_RD_KM);
If I add ->field('id')->in($array), then this distance is suddenly 0. I'm not sure where the information is lost. Is this a limitation on how $ works in MongoDB?
Simon source
share