Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 22765 invoked from network); 19 Jan 2011 23:50:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Jan 2011 23:50:14 -0000 Received: (qmail 6082 invoked by uid 500); 19 Jan 2011 23:50:13 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 6006 invoked by uid 500); 19 Jan 2011 23:50:13 -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 5998 invoked by uid 99); 19 Jan 2011 23:50:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jan 2011 23:50:13 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of randall.leeds@gmail.com designates 209.85.161.52 as permitted sender) Received: from [209.85.161.52] (HELO mail-fx0-f52.google.com) (209.85.161.52) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jan 2011 23:50:08 +0000 Received: by fxm5 with SMTP id 5so4169fxm.11 for ; Wed, 19 Jan 2011 15:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=yyek49DFv+jVZwdhetMjZncfAPk4pKVZP8flAtH+0no=; b=NMwfWhK8EJwhVVcZZHzwOrRfkVKd5ox2Y/tCLJjH/4On/SIeDNJSd7dRLnfecdXCg1 l4c5CtxMXnnMkC6xQsRIpF98I3uYReFKLiBPig0gC5AcDQlRhWZH2+KpdIMAoR+y/2x9 O/9kyEggQfWww5I17avsrqezxmgIRnaljA9UE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=ApcNBuHYVoiH74i53PBblJ33lZOmgmNyLB5eqPADG1VefpvDye4Cy/l/+joK1M9foP nks0RS84TqxXSI5m7YxlS8wIVQvPxy3FDpbo6aAlAv/E4AVxS91zuiNA54WRrsB+gbF8 8wHZNy4XILa6IgUagNvz87ktG8cvZwMXt91u4= MIME-Version: 1.0 Received: by 10.223.112.79 with SMTP id v15mr1328042fap.143.1295480985551; Wed, 19 Jan 2011 15:49:45 -0800 (PST) Received: by 10.223.1.212 with HTTP; Wed, 19 Jan 2011 15:49:45 -0800 (PST) In-Reply-To: References: Date: Wed, 19 Jan 2011 15:49:45 -0800 Message-ID: Subject: Re: Writing View to Get Unique Values in Arrays Across Documents From: Randall Leeds To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Seems like you want to emit the idToRetrieveBy as the key from the map function and the entire array as the value. Reduce function can reduce many arrays to the de-duplicated superset. I'd worry about hitting the reduce limit if you're expecting large arrays. On Wed, Jan 19, 2011 at 15:22, Matthew Woodward wrote: > Been banging my head on this one only briefly but figured I'd ask before > banging further. > > I have documents with a property that's an array. I want to write a view to > retrieve all documents based on an ID in the document (not the document ID, > but another ID that will exist in multiple documents), and the ultimate end > result I want is the distinct/unique values from the array data across these > documents. > > To give a concrete example, let's say I have the following two documents: > > DOCUMENT 1: > idToRetrieveBy: 1 > arrayData: ['Homer','Marge','Bart'] > > DOCUMENT 2: > idToRetrieveBy: 1 > arrayData: ['Homer','Marge','Bart','Lisa','Maggie'] > > From the view, what I'd want to get back is: > ['Homer','Marge','Bart','Lisa','Maggie'] > > Any ideas on how to go about that, or is that something I'd have to crunch > on the application side of things? > > Thanks. > > -- > Matthew Woodward > matt@mattwoodward.com > http://blog.mattwoodward.com > identi.ca / Twitter: @mpwoodward > > Please do not send me proprietary file formats such as Word, PowerPoint, > etc. as attachments. > http://www.gnu.org/philosophy/no-word-attachments.html >