$geoNear with $lookup and $match

Hello! My problem is that I would like to find users who have not yet liked a certain username, but who are from the same area. if I try to write the code as below $ geoNear is not taken into account. How should this be done? thank you!

[ 
	[
	  '$geoNear'=> [
		'near'=> [ 'type'=> 'Point', 'coordinates'=> [1.2744485, 1.5845001] ],
		'distanceField'=> 'distance',
		'$maxDistance'=> 10,
	  ]
	],
	[
	'$lookup'=> [
	  'from'=> "like",
	  'let'=> [ 'username'=> '$username' ],
	  'as'=> "likes",
	  'pipeline'=> [
		[
		  '$match'=> [
				'$expr'=> [
					'$and'=> [
						[ '$eq'=> [ '$likeA', '$username' ] ]
					]
				]
			]
		]
		]
	]],
	[
	'$match'=> [
		'likes.likeA'=> [ '$exists'=> false ]
	]
	]
];

Hello @Mondo_Tech ,

Welcome to The MongoDB Community Forums! :wave:

Could you please help me with below details to understand your use case better?

  • Sample documents
  • Expected Output
  • MongoDB Version

Regards,
Tarun