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.