Having a 2dsphere index on a time series collection can leave out results. Note that it starts to fail at 1001 documents, and a bucket can hold 1000 documents at most.
(function() { "use strict"; load("jstests/core/timeseries/libs/timeseries.js"); const coll = db.collection; coll.drop(); assert.commandWorked( db.createCollection(coll.getName(), {timeseries: {timeField: 'timestamp', metaField: 'meta'}})); Random.srand(1); function random(min, max) { return Random.rand() * (max - min + 1) + min; } function compareResultsWithAndWithoutIndex(){ assert.commandWorked(coll.createIndex({location: '2dsphere'})); const pipeline = [{ "$match": { "location": {"$geoWithin": {"$centerSphere": [[-78.64332757901981, 42.04289085325348], 0.001]}} } }] const results1 = coll.aggregate(pipeline).toArray(); jsTestLog("results1") jsTestLog(results1); assert.commandWorked(coll.dropIndexes()); const results2 = coll.aggregate(pipeline).toArray(); jsTestLog("results2") jsTestLog(results2); assert.eq(results1, results2); } for (let i = 0; i < 1001; ++i) { const doc = { timestamp: new Date(), meta: 1, location: [random(-80.0, -73.0), random(40.0, 45.0)] }; assert.commandWorked(coll.insert(doc)); } compareResultsWithAndWithoutIndex(); })();