简体   繁体   English

格式化MongoDB MapReduce输出

[英]Formatting MongoDB MapReduce output

In all of the MongoDB MapReduce examples that I can find, output is formatted like this: 在我能找到的所有MongoDB MapReduce示例中,输出的格式如下:

{ "_id" : ..., "value" : { "v1" : ..., "v2" : ..., "vn" : ... } }

I would like to know if it is possible to write a MapReduce command to instead format output like this: 我想知道是否可以编写一个MapReduce命令来代替这样格式化输出:

{ "_id" : ..., "v1" : ..., "v2" : ..., "vn" : ... }

If so, what is the best way to accomplish this? 如果是这样,最好的方法是什么?

This is not possible due to the way MR actually writes out. 由于MR实际写入的方式,这是不可能的。

It writes out to a value field, the same rules apply as they did of this question here: In MongoDB mapreduce, how can I flatten the values object? 它写出一个值字段,适用的规则与此处的问题相同: 在MongoDB mapreduce中,如何展平值对象? . To save you from having to click on two links here is the JIRA for your functionality: https://jira.mongodb.org/browse/SERVER-2517 为了使您不必单击两个链接,此处提供了功能强大的JIRA: https : //jira.mongodb.org/browse/SERVER-2517

Of course you could always run some post-processing function after the MR to change the way the collection looks but this is normally unperformant and slow method to do something you could easily handle in your queries. 当然,您总是可以在MR之后运行一些后处理功能,以更改集合的外观,但这通常是性能不佳且缓慢的方法,无法轻松执行查询中的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM