1 / 1
Apr 4

II was using MongoDb Compass for development and have been successfully using $geoNear and $geoWithin for the past few months. I am now using Atlas Free Tier, testing and having some issues returning data with ‘near’ inside $search.
I have 2 documents under my ‘groups’ atlas collection. The geo fields are corrects.


My atlas mapping:

{ "mappings": { "dynamic": true, "fields": { "geo.location": { "type": "geo" } } } }


This code works:

db.groups.aggregate([ { $search: { "index": "groupSearch", "exists": { "path": "geo.location" } } } ]);

This code below does not. I’ve increased the pivot from 1 to billions, same results.

db.groups.aggregate([ { $search: { "index": "groupSearch", "near": { "path": "geo.location", "origin": { "type": "Point", "coordinates": [-113.5752,37.0758] }, "pivot": 1000 } } } ])

Again i’m pretty sure it’s not a data issue because I have ben using geoNear and geoWithin with Compass without issues. My Atlas mapping is pretty standard.
Any idea what’s going on?