Resful Web APIでJavaを使ってgraphlookupを実装する方法を探しています。私はMongoDBの上のような階層を実装しようとしている(https://docs.mongodb.com/v3.4/reference/operator/aggregation/graphLookup/)
{ "_id" : 1, "name" : "Dev" }
{ "_id" : 2, "name" : "Eliot", "reportsTo" : "Dev" }
{ "_id" : 3, "name" : "Ron", "reportsTo" : "Eliot" }
{ "_id" : 4, "name" : "Andrew", "reportsTo" : "Eliot" }
{ "_id" : 5, "name" : "Asya", "reportsTo" : "Ron" }
{ "_id" : 6, "name" : "Dan", "reportsTo" : "Andrew" }
これは、私がしたいことは
{
"_id" : 1,
"name" : "Dev",
"reportingHierarchy" : [ ]
}
{
"_id" : 2,
"name" : "Eliot",
"reportsTo" : "Dev",
"reportingHierarchy" : [
{ "_id" : 1, "name" : "Dev" }
]
}
{
"_id" : 3,
"name" : "Ron",
"reportsTo" : "Eliot",
"reportingHierarchy" : [
{ "_id" : 1, "name" : "Dev" },
{ "_id" : 2, "name" : "Eliot", "reportsTo" : "Dev" }
]
}
I MongoDBの
に保存されている。この構造を作成できるようにするには、従業員のコレクションです「集約のため、このような例を見ましたが、graphlookupAggregation agg = newAggregation(
match(Criteria.where("pageId").is("2210")),
unwind("postIds"),
group("_id").sum("1").as("sum")
//project("$sum").and("pageId").previousOperation()
);
には何も、このような形式にgraphlookup取得する方法はありませんか?ここで、match、unwind、groupを使用する代わりに、GraphLookupOperationを使用して、get map resultのようなものを使用できます。
これは良いことですが、.asにはエラーがあり、アクセスできません。 – Andrew
1.10.6 spring mongoにこのようなエラーはありません。あなたがいる春のmongoのバージョンは何ですか? – Veeram