0

我在 java 中运行这个 mongo MapReduce 查询

MapReduceCommand mrc = new MapReduceCommand(collection, map,reduce, null,MapReduceCommand.OutputType.INLINE,conditions);  
MapReduceOutput out = collection.mapReduce(mrc);  

这工作正常并返回值,但我如何为这些结果设置“跳过”和“限制”?

谢谢

4

1 回答 1

0

有一种方法可以做到这一点,但不完全是我想要的方式,首先我必须将输出保存到新集合中,就像这样

 MapReduceCommand mrc = new MapReduceCommand(collection, map,reduce,"result",MapReduceCommand.OutputType.REPLACE,conditions);  
 MapReduceOutput out = collection.mapReduce(mrc);  

然后,我们可以像这样设置跳过限制

    DBCursor rs = out.getOutputCollection().find() ;
    rs.skip(0).limit(10);  

如果任何机构知道这样做而不将地图减少结果保存到临时集合,请发布,

谢谢

于 2013-02-11T09:30:07.670 回答