看板 Database 關於我們 聯絡資訊
資料庫名稱: MongoDB 資料庫版本: 2.6.2 內容/問題描述: 兩個 Collection : A, B 簡單表示如下: db.A.find() | db.B.find() | { "art_id" : 1 } | { "art_id" : 1 } { "art_id" : 2 } | { "art_id" : 2 } { "art_id" : 3 } | { "art_id" : 3 } { "art_id" : 4 } | { "art_id" : 4 } { "art_id" : 5 } | { "art_id" : 5 } | { "art_id" : 6 } _id 及其他欄位佔版面,故省略不表示。 Q :請問該如何比對 A,B 兩個 collection 並且得到 { "art_id" : 6 } 呢? 補充: 原先想用 db.A.distinct("art_id"); db.B.distinct("art_id"); 的方式取得兩邊的 art_id 做比對 但是因為數量太過龐大 ( A 有十萬多筆資料,B 則是送出查詢許久沒有回應) 故想改用別的方式做查詢, 但是看了 MapReduce 的範例卻不會改寫 (而且也不確定 MapReduce 是否為正確的方向) 因此上來求救,還望大家多多指點, 謝謝。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.250.73.121 ※ 文章網址: https://www.ptt.cc/bbs/Database/M.1424060008.A.4D6.html ※ 編輯: justin761002 (60.250.73.121), 02/16/2015 12:13:47
Hikki520: http://goo.gl/rXGMQY Mapreduce來做join和統計 02/17 19:59