Да. Мой матч работает правильно


но я начал изучать Aggregation Framework в MongoDB с помощью SpringData. Я мог бы создать следующий запрос, т.е.

db.consumer_order.aggregate([
                            { $match: {_id: ObjectId("59e43f542397a00de0c688e4"), "orderState":"Confirmed"}},
                            { $project: {
                                parts: {$filter: {
                                    input: '$parts',
                                    as: 'item',
                                    cond: {$eq: ['$item.currentState', "Estimation Confirmed"]}
                                }}
                            }}
                        ])

с родным драйвером MongoDB весной со следующим кодом

List<Document> aggrigationList = new ArrayList<>();

List<String> conditions = new ArrayList<>();
conditions.add("$item.currentState");
conditions.add("Estimation Confirmed");

Document matchDoc = new Document("$match",new Document("_id",new ObjectId(orderId)));
Document projectDoc = new Document("$project",new Document("parts",new Document("$filter",new Document("input","$parts").append("as", "item").append("cond", new Document("$eq",conditions)))));
aggrigationList.add(matchDoc);
aggrigationList.add(projectDoc);

Document orderWithPendingParts = consumerOrderCollection.aggregate(aggrigationList).first();

Но я знаю, что не всегда полезно работать с Native Driver, поскольку у нас есть Spring-Data. Но у меня возникли проблемы с созданием вышеуказанного запроса MongoDB к AggrigationObject с использованием Spring Data. Я попробовал с ниже, но найти трудности в построенииAggregation.project () т.е.

mongoTemplate.aggregate(Aggregation.newAggregation(
            Aggregation.match(Criteria.where("owner").is(user).andOperator(Criteria.where("orderState").is("confirmed"))),
            ***Finding Difficulty in here***
            ), inputType, outputType)

Направь меня, если я делаю что-то не так.

Ответы на вопрос(1)

Ваш ответ на вопрос