0

My collection Col1 has two fields loc1 and loc2. I need to check if loc1 is father than loc2 by X km. Getting calculated distance would be fine too. I would greatly prefer not to create new collections.

I am dealing with 3.6.7 mongoDB using it's shell for testing. There are 2dsphere indexes on both loc1 and loc2. I failed both with geoNear aggregation and with nearSphere query operator. Both do not like having a variable as there main search parameter.

I expect to either get some "distance" or just to check if loc1 is father than loc2 by X kilometers (like nearShere does with maxDistance)

This is once-in-a-while scheduled script, so I do not care about how fast or efficient it is.

Amantel
  • 659
  • 1
  • 8
  • 18
  • Possible duplicate of [MongoDB print distance between two points](https://stackoverflow.com/questions/33864461/mongodb-print-distance-between-two-points) – Nidhin David May 10 '19 at 09:47
  • Hi David. That question is about the distance from specified point (coordinate pair). And setting up $loc1 as that value in aggregation didn't work for me. – Amantel May 11 '19 at 13:14

0 Answers0