0

我正在尝试 map reduce 中的一个函数,它对数据进行排序并返回它。当输入查询中的所有桶键对都存在于 riak 集群中时,它运行良好。当存储桶/密钥对不存在时,它会给出如下所示的输出。

[{"not_found":{"bucket":"newspaper-issue","key":"56276","keydata":"undefined"}}]

我无法从映射阶段删除此输出,即使我只是return []在映射阶段,它也会返回这个单个对象。

我的问题是如何避免此输出,因为输入中可能缺少一些存储桶/密钥。

地图功能是这样的:

"language" => "javascript",
"source" => "function(value,keyData,arg){
   return []
 },
"keep"=>true
4

1 回答 1

2

I see this was already answered on our mailing list for you but wanted to have the answer available here on SO as well:

There is a builtin JS function to use in your reduce phase to fix this; filterNotFound()

return  Riak.filterNotFound(your_object_passed_from_map_phase);
于 2012-10-01T16:54:21.607 回答