I am trying to run a query that allows to find nearby users given a certain maximum distance. I would like that after finding them, it would randomly take 10 documents among those found and I don’t know how to do it.
i tried using $sample but i got several misuse errors. how should i do?
code:
$result = ["coordinate"=> [
'$near'=> [
'$geometry'=> [
"type"=> "Point" ,
"coordinates" => [ 12.099700 , 45.267670 ]
],
'$maxDistance'=> 40000
]
]];
thanks!