2013-12-19 181 views
0

我有两个collection作为bellow产品有用户参考。我的回报按名称搜索&产品我想用地图相结合的产品和用户的输出减少方法想合并mongo db中的两个集合使用map减少

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

您是否搜索过Google? – Sammaye

回答

0

这可以使用两个地图缩小来完成。

你运行你的第一个MR然后你reduce出第二个MR到第一个结果。

不应该做到这一点虽然。联接不是通过MR完成的,事实上,听起来好像你正在尝试使用inline输出来完成这个MR,这本身就是一个非常糟糕的主意。

MR是而不是设计为内联运行到应用程序。

你会更好地做JOIN其他地方。