Hello,
I am using ‘$regexMatch’ in a ‘$cond’ expression in an aggregation pipeline in Go (see below), but when I run the pipeline, I get the error: “Unrecognized expression ‘$regexMatch’”. I am running v1.11.1 of mongo-driver, and the latest version of Mongo, so there shouldn’t be any issue with versions. Also, I tried the same pipeline in MongoDB Compass and it’s working just fine.
The pipeline I am running is quite elaborate, but I am just putting below the stage to which the error is associated:
addFieldsStage := bson.D{
{
Key: "$addFields",
Value: bson.D{
{Key: "match_whole_name",
Value: bson.D{
{
Key: "$cond",
Value: bson.A{
bson.D{
{
Key: "$regexMatch",
Value: bson.D{
{Key: "input", Value: "$name"},
{Key: "regex", Value: "^ronald$"},
{Key: "options", Value: "i"},
},
},
},
0,
1,
},
},
},
},
},
},
}
I’d be grateful for any thoughts on what the problem could be.
Kind regards,
George