作者justin761002 (铭)
看板Database
标题[Mongo] Collection 之间做比对,取出相异的部份
时间Mon Feb 16 12:13:26 2015
资料库名称: 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://webptt.com/cn.aspx?n=bbs/Database/M.1424060008.A.4D6.html
※ 编辑: justin761002 (60.250.73.121), 02/16/2015 12:13:47