Код: Выделить всё
ProjectionOperation projectionPreUnwind = Aggregation.project(Fields.from(Fields.field("result.detections.reference.control", "result.detections.reference.control")));
UnwindOperation unwindOpn = Aggregation.unwind("result.detections");
Aggregation aggregation = Aggregation.newAggregation(projectionPreUnwind, unwindOpn);
LOGGER.info(" aggregation {}", aggregation);
AggregationResults detectionsDataAggr = mongoTemplate.aggregate(aggregation, CASES_COLLECTION, String.class);
Код: Выделить всё
2024-10-23 16:48:00.097 INFO B33543D --- [nio-8082-exec-9] .c.c.s.d.r.c.i.MyRepoImpl : ENTERING aggregation [!!!org.springframework.data.mongodb.core.aggregation.Aggregation@3fee8ffe=>java.lang.IllegalArgumentException:Invalid reference 'result.detections'!!!!]
java.lang.IllegalArgumentException: неверная ссылка «result.detections»!
в org.springframework.data. mongodb.core.aggregation.ExposeFieldsAggregationOperationContext.getReference(ExposeFieldsAggregationOperationContext.java:114)
at org.springframework.data.mongodb.core.aggregation.ExposeFieldsAggregationOperationContext.getReference(ExposeFieldsAggregationOperationContext.java:77)
в орг. Springframework.data.mongodb.core.aggregation.UnwindOperation.toDocument(UnwindOperation.java:95)
Пример файла JSON
Код: Выделить всё
{
"result": {
"aiModel": "",
"detections": [
{
"aiStatus": "PASS",
"reference": {
"attribute": "TEST",
"control": "C Test"
}
},
{
"aiStatus": "FAIL",
"reference": {
"attribute": "TES22T",
"control": "C Test"
}
}
]
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... wind-issue
Мобильная версия