question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

version 0.5.2 is breaking $geoNear aggregation

See original GitHub issue

Hi, I have the following error with version 0.5.2 when using geo localised queries:

MongoError: $geoNear is only valid as the first stage in a pipeline.

Indeed, the first item in the aggregate query is now “{ $match: { deleted: { ‘$ne’: true } } }” rather than $geoNear.

As a workaround, I’ve overridden the overrideMethods option.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
svengaucommented, Aug 31, 2021

@dsanel, sorry, I don’t work on this project and the related customer anymore. So I won’t be able to reproduce easily.

0reactions
simplenotezycommented, May 17, 2022

@dsanel I have this issue. It happens when you use $geoNear, e.g. like so:

await this.userModel.aggregate([{
	$geoNear: {
		near: userModel.location,
		distanceField: 'distance',
		maxDistance: userModel.maxSuggestionDistance ?? Number.MAX_VALUE,
		key: 'location',
		query: {}, // some random query
	},
}])

My current workaround is to simply disable soft deletes override of aggregate methods.

As an alternative workaround, it would be cool, if you could disable the softdelete for a single query, instead of for all methods. For instance:

await this.userModel.disableSoftDeletes.aggregate([{

That could also be a “quick fix” to this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

$geoNear (aggregation) — MongoDB Manual
Outputs documents in order of nearest to farthest from a specified point. Note. Starting in version 4.2, MongoDB removes the limit and num...
Read more >
Mongo $geoNear query - incorrect nscanned number and ...
I'm pretty sure that mongodb has a limit of 16 MB on the results of $GeoNear. ... while the results of the geonear...
Read more >
Introduction to Python - Cloudmesh Community
9.1.3.13 Aggregation . ... 11.2.0.5.2 AnsiblePlaybook . ... geous to use a newer version of Python, so you can leverage the latest features....
Read more >
geoNear aggregation does not deliver the expected results ...
Hi,. I have 2.000.000 gps locations in my collection. I've added a 2dsphere index on the location field. The location field is a...
Read more >
Big Data Applications - ResearchGate
You will also need Python version 3.7.1 to run the scripts needed to assamble the ... No grading will be conducted over breaks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found