Operational Defect Database

BugZero found this defect 236 days ago.

MongoDB | 2451736

Timeseries $geoNear throws unexpected error with lookup

Last update date:

3/8/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

No fixed releases provided.

Description:

Info

We expect $lookup with $geoNear on a timeseries collection to work as it works on non-timeseries collections. However, $lookup with $geoNear on timeseries is throwing an error. This might be because the geoNear and internalUnpackBucket stages aren't being swapped in optimize when $lookup is used, as it usually is without a $lookup for timeseries.

Top User Comments


Steps to Reproduce

//create a timeseries collection assert.commandWorked(testDB.createCollection(tsColl.getName(), {timeseries: {timeField: timeFieldName, metaField: metaFieldName}})); assert.commandWorked(tsColl.createIndex({'tags.loc': '2dsphere'})); tsColl.insert({ time: ISODate(), tags: {loc: [40, 40], descr: 0}, value: 0 }) const coll2 = db.getCollection("store_min_max_values"); coll2.drop(); assert.commandWorked(coll2.insert({_id: 0, minimumDist: 0.0, maximumDist: kMaxDistance})); coll2.aggregate([{$lookup: {from: tsColl.getName(), let: {minVal: "$minimumDist",maxVal:"$maximumDist"}, pipeline: [ {$geoNear: {near: {type: "Point", coordinates: [0, 0]}, key: 'tags.loc', distanceField: "tags.distance"}}], as: 'output'}}]); // gives err command failed: { "ok" : 0, "errmsg" : "PlanExecutor error during aggregation :: caused by :: $geoNear was not the first stage in the pipeline after optimization. Is optimization disabled or inhibited?", "code" : 40603, "codeName" : "Location40603"

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Backlog

Learn More

Search:

...