Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 225 invoked from network); 4 Apr 2011 16:35:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Apr 2011 16:35:40 -0000 Received: (qmail 66622 invoked by uid 500); 4 Apr 2011 16:35:38 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 66495 invoked by uid 500); 4 Apr 2011 16:35:38 -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 66487 invoked by uid 99); 4 Apr 2011 16:35:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2011 16:35:38 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of luismiguelferreirasilva@gmail.com designates 209.85.212.172 as permitted sender) Received: from [209.85.212.172] (HELO mail-px0-f172.google.com) (209.85.212.172) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2011 16:35:31 +0000 Received: by pxi6 with SMTP id 6so2125640pxi.31 for ; Mon, 04 Apr 2011 09:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=py1WfRsW3QsdEDbldONPD8+1VeyZCqS6cLu1G8QXQhM=; b=mJinje4Z20F60qqvnHgDA/i5WqaOT7MhkrVhahYpzYkYNpiLyZyKSsSC7Xx7Y/nye3 Ff2kHJ9Q9T4xBbVeaOP3A65rdqKqqZbmOfHzHMR7B4bzDqrsHPytPQm5wJ6DhWzx0nGj mEBDjYj5QPe7y1Gae3rynmQZoZGdnakD/DplQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; b=ArIVLw0bTNimiZHTpaWnOYT6T4d3ANedhui95DEI8TDUCUf77qOgA67i0E4xkHzwHE eaH1MjMTLDOrBDt8CqNzmH0PvGQqG68xK3SsSle6nEXf5p0j1ikRgby/Xiycw8725gaR Z0YZ/mNm+nMSxWdzKXpmOiMILTV0ByH2zL5R0= Received: by 10.142.62.9 with SMTP id k9mr6913360wfa.162.1301934911144; Mon, 04 Apr 2011 09:35:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.52.168 with HTTP; Mon, 4 Apr 2011 09:34:48 -0700 (PDT) From: Luis Miguel Silva Date: Mon, 4 Apr 2011 10:34:48 -0600 Message-ID: Subject: How to query a view by key? To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Dear all, I've been reading the docs but i simply cannot understand how to query a view by key?? For instance, let's imagine these 2 documents: { "_id": "esxi4-stateless", "_rev": "2-fe0aeb05ac93d5f5a08d4befc68f10a6", "type": "os", "oslist": [ "SOE-RHEL-5_5-2H10_0-Statelite-pm", "esxi4-stateless", "rhel53-statelite-pm", "rhel54-statelite-pm" ], "vmoslist": [ "rhel48-stateful", "rhel53-stateful", "rhel53-stateful-cluster", "rhel54-stateful", "SOE-RHEL-5_5-2H10_0-Stateful", "rhel54-stateful-cluster", "rhel53-statelite-vm", "rhel54-statelite-vm", "SOE-RHEL-5_5-2H10_0-Statelite-vm", "win2k3-stateful-32-std", "win2k3-stateful-32-ent", "win2k3-stateful-32-ent-cluster", "win2k3-stateful-64-std", "win2k3-stateful-64-ent", "win2k3-stateful-64-ent-cluster", "win2k8-stateful-64-std", "win2k8-stateful-64-ent", "win2k8-stateful-64-ent-cluster", "win2k8R2-stateful-64-std", "win2k8R2-stateful-64-ent", "win2k8R2-stateful-64-ent-cluster", "P2V-WIN,P2V-RHEL" ] } and { "_id": "rhel54-stateful", "_rev": "1-170a66778927ee575ab080a33985d44e", "type": "os", "oslist": [ "SOE-RHEL-5_5-2H10_0-Statelite-pm", "esxi4-stateless", "rhel53-statelite-pm", "rhel54-statelite-pm" ] } So i created this view to query them: function(doc) { if (doc.type =3D=3D "os") { emit(doc._id, { os: doc._id, OSLIST: doc.oslist, VMOSLIST: doc.vmoslist, } ); } } And consuming it directly (http://xkitten.ac:5984/momdb/_design/os/_view/getOS) produces: {"total_rows":2,"offset":0,"rows":[ {"id":"esxi4-stateless","key":"esxi4-stateless","value":{"os":"esxi4-statel= ess","OSLIST":["SOE-RHEL-5_5-2H10_0-Statelite-pm","esxi4-stateless","rhel53= -statelite-pm","rhel54-statelite-pm"],"VMOSLIST":["rhel48-stateful","rhel53= -stateful","rhel53-stateful-cluster","rhel54-stateful","SOE-RHEL-5_5-2H10_0= -Stateful","rhel54-stateful-cluster","rhel53-statelite-vm","rhel54-statelit= e-vm","SOE-RHEL-5_5-2H10_0-Statelite-vm","win2k3-stateful-32-std","win2k3-s= tateful-32-ent","win2k3-stateful-32-ent-cluster","win2k3-stateful-64-std","= win2k3-stateful-64-ent","win2k3-stateful-64-ent-cluster","win2k8-stateful-6= 4-std","win2k8-stateful-64-ent","win2k8-stateful-64-ent-cluster","win2k8R2-= stateful-64-std","win2k8R2-stateful-64-ent","win2k8R2-stateful-64-ent-clust= er","P2V-WIN,P2V-RHEL"]}}, {"id":"rhel54-stateful","key":"rhel54-stateful","value":{"os":"rhel54-state= ful","OSLIST":["SOE-RHEL-5_5-2H10_0-Statelite-pm","esxi4-stateless","rhel53= -statelite-pm","rhel54-statelite-pm"]}} ]} But what about if i just want to get the register for _id =3D "esxi4-statel= ess" ?? I've been trying with: http://xkitten.ac:5984/momdb/_design/os/_view/getOS?key=3D"esxi4-stateless"= &include_docs=3Dtrue http://xkitten.ac:5984/momdb/_design/os/_view/getOS?key=3D["esxi4-stateless= ",1,{}]&include_docs=3Dtrue and a mixture of different things but i JUST can't seem to get it?! Could someone please explain how to correctly query the REST web service to get what i want?? Thanks in advance, Luis