Closed
Description
This is similar to already closed #4285.
If I include $replaceRoot
stage, aggregation fails with CodecConfigurationException
. Below is the (bit anonymized) aggregation itself. Workaround is to use $project
instead of $replaceRoot
(which is not that convenient).
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for CodecCacheKey{clazz=class org.springframework.data.mongodb.core.aggregation.BooleanOperators$And, types=null}.
[
{
"$match": {
"$and": [
{
"fieldA": "some value"
}
]
}
},
{
"$sort": {
"updatedAt": -1
}
},
{
"$group": {
"_id": "$_some_field_id",
"latestRecord": {
"$first": "$$ROOT"
}
}
},
{
"$replaceRoot": {
"newRoot": "$latestRecord"
}
},
{
"$lookup": {
"from": "joinedCollectionName",
"let": {
"fieldB": "$fieldB",
"fieldA": "$fieldA",
"fieldC": "$fieldC"
},
"pipeline": [
{
"$match": {
"$expr": {
"$java": org.springframework.data.mongodb.core.aggregation.BooleanOperators$And@5d77efc8
}
}
}
],
"as": "myAlias"
}
}
]
Some dependency versions:
[INFO] +- org.springframework.boot:spring-boot-starter-data-mongodb:jar:3.3.0:compile
[INFO] | +- org.mongodb:mongodb-driver-sync:jar:5.0.1:compile
[INFO] | | +- org.mongodb:bson:jar:5.0.1:compile
[INFO] | | \- org.mongodb:mongodb-driver-core:jar:5.0.1:compile
[INFO] | | \- org.mongodb:bson-record-codec:jar:5.0.1:runtime
[INFO] | \- org.springframework.data:spring-data-mongodb:jar:4.3.0:compile
[INFO] | +- org.springframework:spring-tx:jar:6.1.8:compile
[INFO] | \- org.springframework.data:spring-data-commons:jar:3.3.0:compile