CouchDB changes feed

Quick post that the “Asynchronous architectures with the CouchDB _changes feed” webcast hosted by O’Reilly Media was good. Unfortunately, what I really want to do is not yet possible out of the box. I want to use the GeoCouch indexer to filter the changes feed. So for example (and liberally inventing the ‘&&’ operator that mimics the same operator from PostGIS)


function(doc, req)
{
if(doc.geometry && req.query.bbox) {
return true;
}
return false;
}

Then a map application could update, say, traffic conditions for the current viewport, rather than sifting through possibly millions of traffic events every few minutes just to find the handful in my area.

The hooks are there, and it might be possible to do a workaround, but I’m not seeing it yet.

I also thought I wanted reduce in the filter, but thinking about it I’ve changed my mind. Taking the Focus app as an example, suppose I want to see who has been active recently, not the actual posted tasks. A reduce in the filter could bundle up just the people making changes, while skipping the actual changes. But I think I understand enough of the underlying architecture of CouchDB to know that there probably isn’t much advantage to computing map/reduce b-trees for changes…by definition these things are changing. If such a thing were really important, one could use the changes feed to populate another db with appropriate documents (and the change timestamp and ordering), which in turn would have whatever map/reduce stuff I need to run.

Advertisements

One thought on “CouchDB changes feed

  1. Hey,

    thanks for the nice feedback :) — on the CouchDB dev@ mailinglist, we have thread about “multi views” which discusses intersecting results from multiple views and GeoCouch.

    Cheers
    Jan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s