I am trying to list the records which are near to my search location. I am getting proper result. But I want to get the records in ascending order on distance. But I don't have distance property in my document.
Please help me how to do this.
My in put data is like
{
"name": "xxxx",
"address": "28 Acacia Road",
"location": { "long": 83.2184815, "lat": 17.6868159 },
}
NOTE : My document doesn't have distance property.
My query builder is
/**
* Get nearby DOS
*
* @param integer $distance
* @param double $longitude
* @param double $latitude
* @param float $earth_radius | 6378.137
*/
public function getListDOS($distance, $longitude, $latitude, $earth_radius)
{
$dm = $this->getDocumentManager();
$qb = $dm->createQueryBuilder('ABCBundle:Document')
->field('location')
->geoNear($longitude,$latitude)
->maxDistance($distance/$earth_radius)
->spherical(true)
->distanceMultiplier($earth_radius)
;
return $qb->getQuery()->execute()->toArray();
}
Thank you