couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Bangert <...@groovie.org>
Subject Re: Associating users and comments
Date Thu, 02 Oct 2008 02:34:12 GMT
On Oct 1, 2008, at 10:21 AM, Paul Davis wrote:

> I can't point at any specific docs just yet, but the thing that made
> it click for me was Chris Anderson's Markov Chain example [1].
>
> So in your view, you'd be doing something like:
>
> function(doc)
> {
>  if(doc.post_id)
>    emit([doc.post_id, doc.comment_id], 1)
>  else
>    emit([doc._id, 0], 1)
> }
>
> Reduce:
>
> function(keys, values)
> {
>    return sum(values);
> }
>
> And then you'd get the row counts for a number of posts would be  
> something like:
>
> http://localhost:5984/db_name/_view/my_reduce_view?group_level=1&startkey= 
> [foo]&endkey=[bar]
>
> The idea here is that when you emit an array key, you can do a
> group_level=blah to only reduce down to the first blah unique
> elements.

Right.... still feels like I'm missing a huge amount of underlying  
knowledge that isn't documented anywhere.... such as:
1) What's the input and output to a map function?
2) What's the input and output, along with options available for a  
reduce function?
3) How abouts do I put in map/reduce functions into a view?

A fairly basic tutorial that shows something simple like a basic blog,  
(I know, the blog example is corny), and walks through how its setup,  
how the things are put into CouchDB, etc. would be invaluable in  
trying to learn this.

Thanks,
Ben
Mime
View raw message