Skip to content

Problems using $geoNear #965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
guicunha opened this issue Sep 21, 2016 · 2 comments
Closed

Problems using $geoNear #965

guicunha opened this issue Sep 21, 2016 · 2 comments

Comments

@guicunha
Copy link

i make a simple raw and don't understand where are the wrong

$proximos = Perfil::raw(function($collection)
{
return $collection->aggregate(
[
'$geoNear' => [
'near' => [
'coordinates' => [-19.927954,-43.938203]
],
'sphercial' => 'true'
]
]);
});

InvalidArgumentException in Aggregate.php line 93:
$pipeline is not a list (unexpected index: "$geoNear")

@guicunha
Copy link
Author

return $collection->aggregate([ [ '$geoNear' => [ 'near' => [ 'coordinates' => [-19.927954,-43.938203], 'type' => 'Point' ], 'distanceField' => 'distancia.calculada', 'spherical' => true ] ]]);

but return nohing in CLI returns

db.perfils.aggregate({
... $geoNear: {
... near: {
... coordinates: [-19.927954,-43.938203],
... type: 'Point'
... },
... distanceField : "distancia",
... spherical: true
... }
... });
{ "_id" : ObjectId("57d086a7269f335d067af2df"), "contato" : { "cep" : "30150150" }, "localizacao" : { "coordinates" : [ -23.555141, -46.635746 ], "type" : "Point" }, "updated_at" : ISODate("2016-09-07T21:29:11.608Z"), "created_at" : ISODate("2016-09-07T21:29:11.608Z"), "distancia" : 413277.8945996578 }

@RafaelPlantard
Copy link

'property_name' => [
	'$nearSphere' => [
		'$geometry'    => [
			'type'        => 'Point',
			'coordinates' => [
				$latitude,
				$longitude
			]
		],
		'$maxDistance' => $rangeInKm * self::meters_per_km
	]
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants