2017-10-05 11 views
0

私はMongoDB集約クエリを持っています。次のクエリのためのSpringブートmongo集約オブジェクトの例が必要です。2つの配列を連結して結果を投影するSpring Mongo集約クエリ

私はconcatArray部分に貼り付けられています
db.case.aggregate([ 
    { $project: { item: { $concatArrays: [ "$workApproval.partItems", "$warrantyClaims.items.items" ] } } } 
    ,{ $unwind : "$item"} 
]) 

、私は春ブーツモンゴ集約で上記のクエリを作成する方法を確認していない、すべてのヘルプは大歓迎です。ここで

答えて

1

は、あなたは以下のとおりです。

List<AggregationOperation> operations = new ArrayList<>(); 
operations.add(
      Aggregation.project() 
        .and("workApproval.partItems").concatArrays("warrantyClaims.items.items").as("item") 
    ); 
operations.add(Aggregation.unwind("item")); 
Aggregation aggregation = Aggregation.newAggregation(operations); 
+0

感謝感謝あなたの助けのためにたくさん、。 – kanchan

関連する問題