【发布时间】:2015-03-12 17:24:22
【问题描述】:
我正在使用 mongodb/mongoid,我在两个不同的集合中使用相同的键、值和返回格式运行两个 map/reduce 进程。
(就像在本教程中一样:http://tebros.com/2011/07/using-mongodb-mapreduce-to-join-2-collections/)
我使用“out”选项来模拟两个输出之间的合并以模拟连接操作...
我的“加入”集合已被很好地填充,但只有当我迭代结果时!
如果我愿意:
Model_A.collection.map_reduce(map_1, reduce).out(reduce: "my_collection) Model_B.collection.map_reduce(map_2, reduce).out(reduce: "my_collection)
不起作用,集合“my_collection”为空!
如果我愿意:
res_A = Model_A.collection.map_reduce(map_1, reduce).out(reduce: "my_collection)
res_A.each 做|资源 | 放置 res.inspect 结束
res_B = Model_B.collection.map_reduce(map_1, reduce).out(reduce: "my_collection)
res_B.each 做 |资源 | 放置 res.inspect 结束
它正在工作,我的收藏“my_collection”很好地填充了“加入”值...
对于大型数据集,在 ruby 中的 Web 应用程序服务器端进行迭代实在是太丑陋了……
有人遇到过这个问题吗?
谢谢
【问题讨论】:
标签: ruby-on-rails mongodb mapreduce mongoid