couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Anderson" <jch...@grabb.it>
Subject Re: flexible filtering needed, with speed.
Date Tue, 19 Aug 2008 04:46:21 GMT
On Mon, Aug 18, 2008 at 8:31 PM, Brad Anderson <brad@sankatygroup.com> wrote:
> So, I thought, should I be doing this in two steps?  Set up the key to be
> store and whatever else I might want to query on (Month or whatever
> timeframe), and return the doc id's as the values on the original query?  I
> would then send in a complex key to do the filtering.  This would require
> waiting for the _bulk_get functionality, and I'd send that list of ID's into
> a 2nd query to get the raw data to send it to 'map'.
>

You have dynamic queries, so unless you can use couchdb to build an
index that works for your queries... maybe emitting each key-value
pair from your documents, like:

var keys = [];
for (key in doc) keys.push(key);
for (key in doc) {
  emit([key, doc[key]], keys);
}

This will give you a sorted index of each key/value pair you deal
with. So for example, if the user is searching by "city" the document
would show up with a value of "Atlanta".

By listing all the document's keys in the value, you can do your
duck-typing from the view value alone without having to load the
document. Only request the documents which have all the necessary
keys.

This is a little complex - it's the sort of thing SQL tries to paper
over. So it depends on your application. It might be a better fit for
RDBMS, but there's a lot that can be expressed with CouchDB.

Hope this is helpful.

Chris




-- 
Chris Anderson
http://jchris.mfdz.com

Mime
View raw message