Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 72330 invoked from network); 20 Jul 2009 03:08:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Jul 2009 03:08:31 -0000 Received: (qmail 72674 invoked by uid 500); 20 Jul 2009 03:09:36 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 72612 invoked by uid 500); 20 Jul 2009 03:09:35 -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 72602 invoked by uid 99); 20 Jul 2009 03:09:35 -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 03:09:35 +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 tommy.chheng@gmail.com designates 209.85.200.168 as permitted sender) Received: from [209.85.200.168] (HELO wf-out-1314.google.com) (209.85.200.168) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jul 2009 03:09:24 +0000 Received: by wf-out-1314.google.com with SMTP id 28so613337wfa.29 for ; Sun, 19 Jul 2009 20:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=pK909a8U6VGoFOfm41wkT2DC7NHHz7hGxAwbChMee98=; b=aGgtIwrdPJriMYtRstcEnbIvq3P77rUcZhmaLuZ6hFRrCsIjtVrcFWTjVIHuVs7MiH r+x4x1LWzDH2hrZLNiW+RT0IwM2pclZxGyMLn7tx0SzyEmovvhEHeXmBULtwqZne88wQ MZRCoCIGCvSod/Qu/rZn9Pz18BFpI1UV33pkA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=o1q7CwEg91Ex+N5pYO9jqONweVPTrMps1NmRI3WOqYozPedi3tgFBhullCFpdV7wdK eEz/FQACjjuvz8MFFuPtxSoL1cHQzoXVSW3fmCLgZFiU/XxPaACouB78eij8Th6wGlqY 1Lq2XalPBRCNj4pSl4eriPlwgO1EeFk3UCQ44= Received: by 10.142.48.7 with SMTP id v7mr1014886wfv.122.1248059343767; Sun, 19 Jul 2009 20:09:03 -0700 (PDT) Received: from dhcp-v006-100.mobile.uci.edu (dhcp-v006-100.mobile.uci.edu [169.234.6.100]) by mx.google.com with ESMTPS id 24sm11646327wfc.37.2009.07.19.20.09.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 19 Jul 2009 20:09:03 -0700 (PDT) Message-Id: From: Tommy Chheng To: user@couchdb.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Subject: Re: multiple key word count query problem Date: Sun, 19 Jul 2009 20:06:44 -0700 References: <9FAC311C-E0DD-430A-AD3D-406E4716E7D8@gmail.com> X-Mailer: Apple Mail (2.935.3) X-Virus-Checked: Checked by ClamAV on apache.org so for keys with two or more parameters, only the first parameter can be used for range selection? the 2nd and remaining keys can only be used for grouping/sorting? the problem with having two views: If i had two views, one for [word, doc] => count and [doc, word] => count; it would be re-doing the same word counting function twice. I'm gonna try to compute the docs word counts and store the results in database itself. thanks, tommy On Jul 19, 2009, at 7:16 PM, Paul Davis wrote: > On Sun, Jul 19, 2009 at 9:14 PM, Tommy > Chheng wrote: >> I have a simple word count view defined as: >> -------- >> function(doc) { >> if(doc['couchrest-type'] == 'NsfGrant'){ >> var words = doc['abstract'].split(/\W+/); >> words.forEach(function(word){ >> if (word.length > 1) emit([word, doc['_id']],1); >> }); >> } >> } >> >> function(keys, values, rereduce) { >> return 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= >> ["the"]&endkey=["the",{}]&group_level=2 >> >> 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= >> [null,"0808605"]&group_level=2 >> which gives nothing(thinking that null would match all words) >> and >> http://localhost:5984/nsf_grants/_design/NsfGrant/_view/by_word_doc_count?startkey= >> [null,"0808605"]&endkey=[{},"0808605"]&group_level=2 >> 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