diff options
-rw-r--r-- | jstests/aggregation/sources/geonear/requires_geo_index.js | 12 | ||||
-rw-r--r-- | src/mongo/db/pipeline/document_source_geo_near_cursor.cpp | 3 |
2 files changed, 10 insertions, 5 deletions
diff --git a/jstests/aggregation/sources/geonear/requires_geo_index.js b/jstests/aggregation/sources/geonear/requires_geo_index.js index cd8a75c4e29..b56c24b45ef 100644 --- a/jstests/aggregation/sources/geonear/requires_geo_index.js +++ b/jstests/aggregation/sources/geonear/requires_geo_index.js @@ -38,8 +38,8 @@ const geonearWithinLookupPipeline = [ }, ]; -assert.commandWorked(coll.insert({_id: 5, x: 5})); -assert.commandWorked(from.insert({_id: 1, geo: [0, 0]})); +assert.commandWorked(coll.insert({_id: 5, x: 5, geo: [1, 1]})); +assert.commandWorked(from.insert({_id: 1, x: 5, geo: [0, 0]})); // Fail without index. assertErrorCode(from, geonearPipeline, ErrorCodes.IndexNotFound); @@ -50,4 +50,12 @@ assert.commandWorked(from.createIndex({geo: "2dsphere"})); // Run successfully when you have the geospatial index. assert.eq(from.aggregate(geonearPipeline).itcount(), 1); assert.eq(coll.aggregate(geonearWithinLookupPipeline).itcount(), 1); + +// Test that we can run a pipeline with a $geoNear stage followed by a $lookup. +const geonearThenLookupPipeline = [ + {$geoNear: {near: [0, 1], distanceField: "distance", spherical: true}}, + {$lookup: {from: from.getName(), localField: "x", foreignField: "x", as: "new"}}, +]; +assert.commandWorked(coll.createIndex({geo: "2dsphere"})); +assert.eq(coll.aggregate(geonearThenLookupPipeline).itcount(), 1); }()); diff --git a/src/mongo/db/pipeline/document_source_geo_near_cursor.cpp b/src/mongo/db/pipeline/document_source_geo_near_cursor.cpp index 27e72886225..8de9f300ab9 100644 --- a/src/mongo/db/pipeline/document_source_geo_near_cursor.cpp +++ b/src/mongo/db/pipeline/document_source_geo_near_cursor.cpp @@ -77,9 +77,6 @@ DocumentSourceGeoNearCursor::DocumentSourceGeoNearCursor( _distanceField(std::move(distanceField)), _locationField(std::move(locationField)), _distanceMultiplier(distanceMultiplier) { - tassert(6466203, - "$geoNear cursor shouldn't have secondary collections", - collections.getSecondaryCollections().empty()); invariant(_distanceMultiplier >= 0); } |