Hi,
can anyone explain why rtrim operator is not working in the following context:
db.movies.aggregate([
{$match:{
"writers":{$elemMatch:{$exists:true}}
}
},{$project:{
"_id":0,
"title":1,
"writers":{
$map:{
input:"$writers",
as:"writer",
in: {$rtrim:{
input:{$arrayElemAt:[{$split:["$$writer","("]},0]},
chars:" "
}
}
}
}
}
}
]);
I receive the following error when I execute it:
2019-09-23T10:03:13.737+0300 E QUERY [js] Error: command failed: {
āoperationTimeā : Timestamp(1569222188, 1),
āokā : 0,
āerrmsgā : āUnrecognized expression ā$rtrimāā,
ācodeā : 168,
ācodeNameā : āInvalidPipelineOperatorā,
ā$clusterTimeā : {
āclusterTimeā : Timestamp(1569222188, 1),
āsignatureā : {
āhashā : BinData(0,āZ4MavG7sAV58pz3Ca/mm2lr+U4Q=ā),
ākeyIdā : NumberLong(ā6698341139830800385ā)
}
}
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:583:17
assert.commandWorked@src/mongo/shell/assert.js:673:16
DB.prototype._runAggregate@src/mongo/shell/db.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1012:12
Thanks,
Florin