Hey All,

I've recently been toying around with writing some Erlang views and have found 
the experience enjoyable so far, with one caveat. My map function is returning 
bad integers. I'm not sure what the cause could be, but if you guys could point 
me in the right direction, I'd greatly appreciate it. Below is some info I 
think will help.

Map View:
fun({Doc}) ->
  DocumentID = proplists:get_value(<<"_id">>, Doc),
  case DocumentID == <<"campaigns">> of
    true ->
      AdwordsCampaigns = proplists:get_value(<<"adwords">>, Doc, null),
      [Emit(proplists:get_value(<<"id">>, StrippedCampaign, null), Campaign) || 
Campaign <- AdwordsCampaigns, {StrippedCampaign} <- AdwordsCampaigns];
    false -> ignore
  end

end.

It's pretty straightforward. I'm accessing one document called "campaigns", and 
emitting rows with the campaign id as the key, and a performance data capture 
as the value. Or at least that's what I'm trying to do. Output example:

Key: 53518364
Value: {adserving: "OPTIMIZE",   name: "Changed to protect the innocent",   
automatch: "OPT_OUT",   id:50573744,   serving: "SERVING",   client_id: 
3455237823,   strategy: "ManualCPC",   status: "ACTIVE"}

As you can see, the key does not match up to the value I requested from Couch. 
My first thought was that maybe "id" was a bad choice for a key and that it 
might be conflicting with something in the erlang view server, so I tried 
pulling "client_id" instead with a similar result. The integer returned was 
different, but it still didn't match up with my request. Pulling "status", and 
"strategy" was successful and returned the correct string.

Any ideas?

Thanks in advance!

Mike Keen

Reply via email to