Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 19485 invoked from network); 13 Feb 2009 07:54:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Feb 2009 07:54:21 -0000 Received: (qmail 97794 invoked by uid 500); 13 Feb 2009 07:54:20 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 97755 invoked by uid 500); 13 Feb 2009 07:54:20 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 97744 invoked by uid 99); 13 Feb 2009 07:54:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2009 23:54:20 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Feb 2009 07:54:19 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 874F2234C48B for ; Thu, 12 Feb 2009 23:53:59 -0800 (PST) Message-ID: <697373086.1234511639549.JavaMail.jira@brutus> Date: Thu, 12 Feb 2009 23:53:59 -0800 (PST) From: "Viacheslav Seledkin (JIRA)" To: dev@couchdb.apache.org Subject: [jira] Commented: (COUCHDB-249) Treat output rows of views as documents for other views to build upon In-Reply-To: <255502651.1234456679756.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/COUCHDB-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12673169#action_12673169 ] Viacheslav Seledkin commented on COUCHDB-249: --------------------------------------------- I support this requirement. In my project I had to implement it by myself to perform computation schema what are not possible to implement using current view implementation. I am new with Erlang and my implementation is probably not efficient and reliable. I prefer to see this feature as built in CouchDB. > Treat output rows of views as documents for other views to build upon > --------------------------------------------------------------------- > > Key: COUCHDB-249 > URL: https://issues.apache.org/jira/browse/COUCHDB-249 > Project: CouchDB > Issue Type: New Feature > Components: Database Core, Infrastructure, JavaScript View Server > Reporter: Joey Lawrance > > Unless I manually copy the JSON rows of a view into a new document, I am unable to create new views that are computed from existing views. That is, it seems as if views are second class citizens compared to first-class documents. > Suppose I wanted to find the spread between the cheapest suppliers and the most expensive suppliers of each fruit. I know it's possible to use one map/reduce to compute such a view, but I'd like to be able to re-use my existing "cheapest" and "costliest" views. That is, I'd like to use the document output of these views as input into another view. > I started with the simple fruit store example in the CouchDB book. I developed a simple view called "cheapest" with the following map and reduce functions (the "costliest" view is the same as "cheapest" but except the reduce function's comparison is the other way around): > function(doc) { > var store, price, key; > if (doc.item && doc.prices) { > for (store in doc.prices) { > price = doc.prices[store]; > key = doc.item; > emit(key, {store:store, price:price}); > } > } > } > function(item,store) { > var m = store[0]; > for (i in store) { > if (m.price > store[i].price) m = store[i]; > } > return m; > } > The output is as follows: > {"rows":[ > {"key":"apple","value":{"store":"Apples Express","price":0.79}}, > {"key":"banana","value":{"store":"Price Max","price":079}}, > {"key":"orange","value":{"store":"Citrus Circus","price":1.09}} > ]} > I'd like to develop a new view whose input is the output of the view above, but as far as I can tell, views only operate on documents, not the output of existing views. Am I missing something? -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.