couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mathijs Kwik (JIRA)" <j...@apache.org>
Subject [jira] Commented: (COUCHDB-249) Treat output rows of views as documents for other views to build upon
Date Wed, 03 Mar 2010 11:14:27 GMT

    [ https://issues.apache.org/jira/browse/COUCHDB-249?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840582#action_12840582
] 

Mathijs Kwik commented on COUCHDB-249:
--------------------------------------

What's the status of this ticket?

I would like this functionality very much. I tried the patch on 0.10 but it didn't apply :(
For now I need an external process to watch _changes and feed this into new documents, but
it would be much nicer if couch could handle this by itself.

Any progress?
Any related tickets? (couldn't find any myself)


> 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
>         Attachments: couch_view_updaer.erl.patch.txt, couch_view_updater.erl
>
>
> 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.


Mime
View raw message