You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by kowsik <ko...@gmail.com> on 2008/10/16 01:18:19 UTC

Document subsets...

I have a large number of fairly large documents in the db and would
like to get at subsets (specific key/value pairs). In the interest of
latency and data transfer, I usually end up with numerous _design
views that slice and dice a given document and return the subset of
the documents. Instead of doing that, I'm thinking something like this
would be useful:

POST /<db>/_slice?id=blah
Content-Type: application/json
Content-Length: ...

function(doc) {
    emit({ key1: doc.key1, key2: doc.key2 });
}

where "blah" is the _id of the document. Invoking _slice without the
POST body is equivalent to doing "GET /<db>/<blah>" which returns the
entire document.

The big advantage is that once I end up with a docid using the normal
_design views, I can get at specific portion of the document without
necessarily writing numerous _design views. Since this just runs on a
given document, you don't incur the penalty of adhoc views.

Thoughts?

K.

Re: Document subsets...

Posted by Chris Anderson <jc...@apache.org>.
On Wed, Oct 15, 2008 at 4:18 PM, kowsik <ko...@gmail.com> wrote:
>
> POST /<db>/_slice?id=blah
> Content-Type: application/json
> Content-Length: ...
>
> function(doc) {
>    emit({ key1: doc.key1, key2: doc.key2 });
> }
>

Once the external patch has been applied, interfaces like this ought
to be easy to add. The external patch is lets you run view-server like
functions, at query time.



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