我有两个集合作为bellow产品有用户参考。我按名称搜索产品&作为回报,我想使用map reduce方法将产品和用户的输出结合起来
user collection
{
"_id" : ObjectId("52ac5dd1fb670c2007000000"),
"company" : {
"about" : "This is textile machinery dealer",
"contactAddress" : [{
"address" : "abcd",
"city" : "52ac4bc6fb670c1007000000",
"zipcode" : "39as46as80"
},{
"address" : "abcd",
"city" : "52ac4bc6fb670c1007000000",
"zipcode" : "39as46as80"
}],
"fax" : "58784868",
"mainProducts" : "ads,asd,asd",
"mobileNumber" : "9537236588",
"name" : "krishna steels",
}
"user" : ObjectId("52ac4eb7fb670c0c07000000")
}
product colletion
{
"_id" : ObjectId("52ac5722fb670cf806000002"),
"category" : "52a2a9cc48a508b80e00001d",
"deliveryTime" : "10 days after received the ",
"price" : {
"minPrice" : "2000",
"maxPrice" : "3000",
"perUnit" : "5288ac6f7c104203e0976851",
"currency" : "INR"
},
"productName" : "New Mobile Solar Charger with Carabiner",
"rejectReason" : "",
"status" : 1,
"user" : ObjectId("52ac4eb7fb670c0c07000000")
}
答案 0 :(得分:0)
这不可能。 Mongo仅在一个集合上支持Map Reduce。您可以尝试在java集合中获取和合并。几天后我用java集合解决了类似的问题。
Click to see similar response about joins and multi collection not supported in mongo
答案 1 :(得分:0)
这可以使用两个map reduce来完成。
你运行你的第一个MR然后你reduce
将第二个MR运行到第一个MR的结果上。
你不应该这样做。 JOIN并非旨在通过MR完成,实际上听起来你正试图用inline
输出这个MR,这本身就是一个非常糟糕的主意。
MR 不旨在内联到应用程序。
你最好在其他地方做JOIN。