Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 42C5C9ED7 for ; Sun, 20 Nov 2011 18:06:24 +0000 (UTC) Received: (qmail 7461 invoked by uid 500); 20 Nov 2011 18:06:22 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 7437 invoked by uid 500); 20 Nov 2011 18:06:22 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 7429 invoked by uid 99); 20 Nov 2011 18:06:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2011 18:06:22 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Nov 2011 18:06:17 +0000 Received: by vbbfp1 with SMTP id fp1so2298828vbb.11 for ; Sun, 20 Nov 2011 10:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=EaaH7Sf/DHzZBcgo5I4qCNaV1Wa4mKBF3OiwuooOi6M=; b=Kz2FMfBJ/XcHGfsxaa9+WNAhXAjCwN5CzFKjKiZVXkD/U1HnFB5iWEHQB9d5Bj6siZ G6cd6kaNhLbzxKQ/WSGRDi5U4SR7Ts/mjgec864L3abofvLq0kz/VuP9Gh3QIHJxavdb Yd+hMHki0Bz9l2qCblFH7SRcdPRoxxbwWlRfI= Received: by 10.52.240.162 with SMTP id wb2mr12040784vdc.115.1321812357078; Sun, 20 Nov 2011 10:05:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.189.70 with HTTP; Sun, 20 Nov 2011 10:05:16 -0800 (PST) In-Reply-To: References: From: Paul Davis Date: Sun, 20 Nov 2011 12:05:16 -0600 Message-ID: Subject: Re: Erlang view question To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 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 a= nd strings. > > --Jens > > On Nov 20, 2011, at 9:38 AM, "Luke Bredeson" wr= ote: > >> Hi, >> >> I have an Erlang view that is outputting a list of integers instead of a >> string. =A0I know Erlang treats strings as lists of integers, but I thou= ght >> CouchDB would take care of this for me. =A0I'm sure it's a basic error o= n my >> part, so if anyone has any ideas of what I'm doing wrong, I'd appreciate >> it! =A0Here's the relevant map function: >> >> =A0 =A0 =A0fun({Doc}) -> >> =A0 =A0 =A0 =A0case couch_util:get_value(<<"type">>, Doc) of >> =A0 =A0 =A0 =A0 =A0<<"Crash">> -> >> =A0 =A0 =A0 =A0 =A0 =A0Accdate =3D couch_util:get_value(<<"accdate">>, D= oc), >> =A0 =A0 =A0 =A0 =A0 =A0Year =3D string:substr(erlang:bitstring_to_list(A= ccdate), 7, 4), >> =A0 =A0 =A0 =A0 =A0 =A0Emit([couch_util:get_value(<<"city">>, Doc), Year= ], 1); >> =A0 =A0 =A0 =A0 =A0_ -> >> =A0 =A0 =A0 =A0 =A0 =A0ok >> =A0 =A0 =A0 =A0end >> =A0 =A0 =A0end. >> >> I get values like: =A0["3425", [50, 48, 48, 56]], when I'm really lookin= g for >> values like this: =A0["3425", "2008"]. >> >> Thanks, >> Luke >