Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 54476 invoked from network); 20 Jul 2009 02:15:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Jul 2009 02:15:26 -0000 Received: (qmail 42157 invoked by uid 500); 20 Jul 2009 02:16:30 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 42052 invoked by uid 500); 20 Jul 2009 02:16:30 -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 42042 invoked by uid 99); 20 Jul 2009 02:16:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jul 2009 02:16:30 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.132.240 as permitted sender) Received: from [209.85.132.240] (HELO an-out-0708.google.com) (209.85.132.240) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jul 2009 02:16:21 +0000 Received: by an-out-0708.google.com with SMTP id b2so906939ana.5 for ; Sun, 19 Jul 2009 19:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=D4fH9h8FUK5A+SVw1ILISSaDJaYHbgvTRLL3kEADVN8=; b=n0L1JT00EULcWd7HWN4M26kzOnG1PlTirn/eRpCt1ifH7Vk63salhrqu+xBHJ3Aemw TMdrmGZjd8rj9Xolf3oNO1Kv0LUcJ7FrQ0JsL5pMIEMo8JbW1iGxcFbkKcuEySSeC9iz KpHOOLcTvOlDJmmYP0852msBUT/LrgwlknCio= 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:content-transfer-encoding; b=HMEAGyPWx8TasPysfL4xD9JuouESxmQQ0X9Z5xdJslGm9rTanrJ6k0pa2Ai3rRLfHE AVce+9HyEyBEIgZ0aMIrDSa0vJIjlYYYZ6yzKGwDl5nCmNMcd6FowQLfkI+/3gUya+iR wEQQKTFiUVHMQayY2oxvXiVL2pNre8I3bYPLk= MIME-Version: 1.0 Received: by 10.100.109.13 with SMTP id h13mr5597259anc.16.1248056160550; Sun, 19 Jul 2009 19:16:00 -0700 (PDT) In-Reply-To: <9FAC311C-E0DD-430A-AD3D-406E4716E7D8@gmail.com> References: <9FAC311C-E0DD-430A-AD3D-406E4716E7D8@gmail.com> Date: Sun, 19 Jul 2009 22:16:00 -0400 Message-ID: Subject: Re: multiple key word count query problem From: Paul Davis To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Sun, Jul 19, 2009 at 9:14 PM, Tommy Chheng wrote= : > I have a simple word count view defined as: > -------- > function(doc) { > =A0if(doc['couchrest-type'] =3D=3D 'NsfGrant'){ > =A0 =A0var words =3D doc['abstract'].split(/\W+/); > =A0 =A0words.forEach(function(word){ > =A0 =A0 =A0if (word.length > 1) emit([word, doc['_id']],1); > =A0 =A0}); > =A0} > } > > function(keys, values, rereduce) { > =A0return sum(values); > } > -------- > where the key's first parameter is the word and the 2nd parameter is the > document_id. > > so i can do a query like this to get all the documents with the word "the= " > correctly. > http://localhost:5984/nsf_grants/_design/NsfGrant/_view/by_word_doc_count= ?startkey=3D["the"]&endkey=3D["the",{}]&group_level=3D2 > > I'm having trouble doing queries on the 2nd parameter, how can i find all > the words in a particular document? > I tried > http://localhost:5984/nsf_grants/_design/NsfGrant/_view/by_word_doc_count= ?key=3D[null,"0808605"]&group_level=3D2 > which gives nothing(thinking that null would match all words) > and > http://localhost:5984/nsf_grants/_design/NsfGrant/_view/by_word_doc_count= ?startkey=3D[null,"0808605"]&endkey=3D[{},"0808605"]&group_level=3D2 > which gives all results. Why is this? > > Thanks, > Tommy > Querying a view is asking for a slice of a sorted list. Start and end keys delimit the range of rows returned. The solution to your problem is to create a second view so you can query by docid. Paul Davis