I've been working on converting mongodb pipelines to documentdb pipelines. I've posted the same question over on stackoverflow.
I've came across this oddity: I'm seeing behavior where multiplying by negative numbers is failing in AWS documentdb. This works in mongodb but the same fails in documentdb:
"$addFields" : {
sigh: { $multiply: [ NumberInt(-1), NumberInt(1) ] }
}
Just to convince myself that I had the syntax correct I tested against:
"$addFields" : {
sigh: { $multiply: [ NumberInt(1), NumberInt(1) ] }
}
Using -1
works in this toy query but still fails in the same way in the context of a$cond
query.
"$addFields" : {
sigh: { $multiply: -1, NumberInt(1) ] }
}
I thought maybe the NumberInt(-1)
could be the problem but this works just fine:
"$addFields" : {
"sigh2": NumberInt(-1),
}
document db engine: db.runCommand({getEngineVersion: 1}
{
"engineVersion" : "2.0.8934",
"ok" : 1.0,
"operationTime" : Timestamp(1684438041, 1)
}
Finally, the error I'm seeing is:
Mongo Server error (MongoCommandException): Command failed with error 17287: 'Bad query specified' on server <instance>.docdb.amazonaws.com:27017.
The full response is:
{
"ok" : 0.0,
"operationTime" : Timestamp(1684439496, 1),
"code" : 17287.0,
"errmsg" : "Bad query specified"
}