Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 39598 invoked from network); 25 Jan 2011 00:01:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jan 2011 00:01:20 -0000 Received: (qmail 32936 invoked by uid 500); 25 Jan 2011 00:01:18 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 32890 invoked by uid 500); 25 Jan 2011 00:01:17 -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 32881 invoked by uid 99); 25 Jan 2011 00:01:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jan 2011 00:01:17 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.82.180] (HELO mail-wy0-f180.google.com) (74.125.82.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Jan 2011 00:01:10 +0000 Received: by wyb28 with SMTP id 28so4678212wyb.11 for ; Mon, 24 Jan 2011 16:00:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.133.16 with SMTP id d16mr5306917wbt.145.1295913649283; Mon, 24 Jan 2011 16:00:49 -0800 (PST) Received: by 10.227.150.103 with HTTP; Mon, 24 Jan 2011 16:00:49 -0800 (PST) X-Originating-IP: [156.33.195.149] Date: Mon, 24 Jan 2011 16:00:49 -0800 Message-ID: Subject: Start and End Key with Map as Part of Key From: Matthew Woodward To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0016e659f780b9a39c049aa0682f X-Virus-Checked: Checked by ClamAV on apache.org --0016e659f780b9a39c049aa0682f Content-Type: text/plain; charset=ISO-8859-1 This is actually from another thread but since it might have gotten buried by the end (and was a bit of a change in topic) I hope folks don't mind the "repost." I have the following map function: function(doc) { if (doc.office != '' && doc.witnesses != '[]') { doc.witnesses.forEach(function(witness) { if (witness.firstName != '' && witness.lastName != '') { var wit = {}; wit.firstName = witness.firstName; wit.lastName = witness.lastName; emit([doc.office, wit], null); } }); } } With a reduce and ?group=true this outputs things like: {"key":["Office1",{"firstName":"Francine","lastName":"Smith"}],"value":true}, {"key":["Office2",{"firstName":"Stan","lastName":"Smith"}],"value":true} In other instances where my key is an array and the second value is a string (let's use a date string as an example), I do something like this: http://server/database/_design/foo/_view/bar?group=true&startkey=[ "Baz","01/01/2011"],&endkey=["Baz",{}] That will give me all results with "Baz" in the first array element, starting with 01/01/2011, and then all the rest of results for Baz regardless of what the date is via the {} in the endkey. In the case of this data, however, if I want to get back all witnesses for a specific office this doesn't work: http://server/database/_design/witnesses/_view/byOffice?group=true&startkey=[ "Office1"]&endkey=["Office1",{}] That yields 0 rows. If I do this, it works in terms of *starting* with the correct office, but I can't figure out the correct endkey to get it to only show witnesses for that particular office: http://server/database/_design/witnesses/_view/byOffice?group=true&startkey=[ "Office1"] Is this because the second element of my array key isn't a string? 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 --0016e659f780b9a39c049aa0682f--