Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 73017 invoked from network); 11 Nov 2010 16:35:20 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Nov 2010 16:35:20 -0000 Received: (qmail 10424 invoked by uid 500); 11 Nov 2010 16:35:50 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 10378 invoked by uid 500); 11 Nov 2010 16:35:49 -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 10370 invoked by uid 99); 11 Nov 2010 16:35:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 16:35:49 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of th4ngnh0c@gmail.com designates 74.125.83.52 as permitted sender) Received: from [74.125.83.52] (HELO mail-gw0-f52.google.com) (74.125.83.52) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Nov 2010 16:35:41 +0000 Received: by gwj22 with SMTP id 22so1351795gwj.11 for ; Thu, 11 Nov 2010 08:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=SH7qrJkO36uNdrq4gG4VXm7MDMQ1Qg+6orNxYYW3Wf0=; b=U3QUcBzWk+cPaK6VcKvkXY/AE1YG7o49WJL73uohOZ3r9gt7FIoNL0+MFMtFfVTzgI tkOvbGYO1O3E7z140gmeDPNvt0h/R1McNcAxoLdAiNuhaeKomsgyijnyzSTckCi5FiPE YKbVP/gIHUe9hKu3gwaSQWQW8Aae/mZ3igY2I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=vjho/t7TqJ8GOD75WR2Mb6cUPdnfjZtHYGBVu13Cbdtg9LiXbSBe2ySi9PMvmEz6Kh XA8cdyK/qFnaWVuxdWC6SHHfEYiIJhBWenU44ZlfhPQzCcjBfa2BbySV0bN9xWa0xLEm ZyW+XIhMNj/MPlgbexj7wA8G3i43L9mI37+Fs= MIME-Version: 1.0 Received: by 10.42.28.72 with SMTP id m8mr915861icc.446.1289493312887; Thu, 11 Nov 2010 08:35:12 -0800 (PST) Received: by 10.42.164.198 with HTTP; Thu, 11 Nov 2010 08:35:12 -0800 (PST) Date: Thu, 11 Nov 2010 11:35:12 -0500 Message-ID: Subject: Join Query View From: Duc Phan To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=20cf301cc0eadadab30494c98e49 X-Virus-Checked: Checked by ClamAV on apache.org --20cf301cc0eadadab30494c98e49 Content-Type: text/plain; charset=ISO-8859-1 Hello all, I am fairly new to couchDB and the Map/Reduce framework. I am having problems creating a join view. For example: I have multiple documents in these two formats First ------------------------------ ------------- Type : Inventory ID: someID Name: someName Location: someLocation Serial: someSerial ------------------------------------------ Second ----------------------------------------- Type: Machine Serial: someSerial Model: someModel OS: someOS RAM: someRAMsize HD: someHDsize Here is what I am trying to do... in SQL > Select ID, Name, Location, Type, Model, OS, RAM, HD from Inventory, Machine where Inventory.Serial = Machine.Serial That would join the two tables where the Serials match up. How would I do that in couchDB where I have multiple documents with Type: Inventory and Type: Machine I would like the output to be something like: {"ID":"someID","Name":"someName","Location":"someLocation","Serial":"someSerial","Model":"someModel","OS":"someOS","RAM":"someRAMsize","HD":"someHDsize"} for all the machines I have read couchDB the definitive guide and many blogs but I still haven't found a way to solve my problem. My attempt: Map: function(doc){ if (doc.Type == "Inventory"){ emit ([doc.SERIAL,0],doc);} else if (doc.Type == "Machine"){ emit([doc.SERIAL,1],doc);} } Reduce: ? What should I do here. Thank you in advance for any suggestions or help. --20cf301cc0eadadab30494c98e49--