Quite correct. This map function is emitting "2008" vs <<"2008">>. Change to fix it should be:
Emit([couch_util:get_value(<<"city">>, Doc), list_to_binary(Year)], 1); On Sun, Nov 20, 2011 at 12:00 PM, Jens Alfke <[email protected]> wrote: > I'm pretty sure that you need to return all strings as binary objects, as > that's the way Erlang's JSON mapping tells the difference between arrays and > strings. > > --Jens > > On Nov 20, 2011, at 9:38 AM, "Luke Bredeson" <[email protected]> wrote: > >> Hi, >> >> I have an Erlang view that is outputting a list of integers instead of a >> string. I know Erlang treats strings as lists of integers, but I thought >> CouchDB would take care of this for me. I'm sure it's a basic error on my >> part, so if anyone has any ideas of what I'm doing wrong, I'd appreciate >> it! Here's the relevant map function: >> >> fun({Doc}) -> >> case couch_util:get_value(<<"type">>, Doc) of >> <<"Crash">> -> >> Accdate = couch_util:get_value(<<"accdate">>, Doc), >> Year = string:substr(erlang:bitstring_to_list(Accdate), 7, 4), >> Emit([couch_util:get_value(<<"city">>, Doc), Year], 1); >> _ -> >> ok >> end >> end. >> >> I get values like: ["3425", [50, 48, 48, 56]], when I'm really looking for >> values like this: ["3425", "2008"]. >> >> Thanks, >> Luke >
