| 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"
|
|