0

I was trying a function in map reduce which sorts the data and returns it. It works well when all the bucket key pairs in input query exist in the riak cluster. When a bucket/key pair does not exist, it gives an output like below.

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

I'm not able to remove this output from the map phase, even when I just return [] in the map phase, it returns this single object.

My question is how can I avoid this output as it is likely that in the inputs there is some bucket/key missing.

Map function is like this:

"language" => "javascript",
"source" => "function(value,keyData,arg){
   return []
 },
"keep"=>true
Mridul Kashatria
  • 4,157
  • 2
  • 18
  • 15

1 Answers1

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);
Brian Roach
  • 76,169
  • 12
  • 136
  • 161