我正在合并来自两个集合projects
和card_types
聚合管道的记录,然后尝试cardFields
从结果中删除合并记录的字段。所以这个想法是从汇总结果来看
{
"projectId": "foo",
...
"cardTypes": [
{
"itemId": "bar",
"itemType": "Defect",
"cardFields": [ { ... more objects here ...} ]
},
{
... more card types ...
}
],
}
进入
{
"projectId": "foo",
...
"cardTypes": [
{
"itemId": "bar",
"itemType": "Defect"
...
},
{
... more card types ...
}
],
}
我写的方法是
public Flux<Document> getProjectDetails(String enterpriseId, String projectId) {
AggregationOperation unset = UnsetOperation.unset("cardTypes.cardFields");
return mongoOperations.aggregate(
Aggregation.newAggregation(match(where(accountIdKeyName).is(enterpriseId).and(ownerIdKeyName).is(projectId)),
lookup("card_types", accountIdKeyName, accountIdKeyName, "cardTypes"),
unset), "project", Document.class);
}
该方法因异常而失败
org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 40324 (Location40324): 'Unrecognized pipeline stage name: '$unset''