couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <>
Subject Re: Inconsistencies (?) when querying reduce views
Date Mon, 14 Sep 2009 05:22:45 GMT
On Thu, Sep 10, 2009 at 10:26 AM, Paul Davis
<> wrote:
> On Thu, Sep 10, 2009 at 12:58 PM, Brian Candler<> wrote:
>> I've noticed a couple of possible inconsistences in querying a reduce view,
>> which I thought I'd raise here rather than in JIRA for now.
>> I am comparing querying a reduce view with a single key in the URL, versus
>> querying it with a single key in a POST fetch. That is,
>> GET /db/_design/ddoc/_view/vname?key=%22abc%22
>> vs.
>> POST /db/_design/ddoc/_view/vname
>> {keys:["abc"]}
>> (1) If you perform a multi-key fetch as above, it is refused with
>> "query_parse_error", "multi-key fetchs for reduce view must include
>> `group=true`", until you add ?group=true to the URL. However you do not need
>> to do this for the single-key case.
>> (2) In the single key case, you get "key":null in the response row, whereas
>> in the multi-key fetch you get "key":"abc" or whatever the actual key was.
>> Apart from this, both give a response in the same format, i.e.
>> {"rows":[
>> {"key":null,"value":123}
>> ]}
>> Any comments on this? I would have thought that the two should work in the
>> same way.
>> Regards,
>> Brian.
> That is a bit of an awkward inconsistency.
> What's going on is that ?key="foo" is internally equivalent to
> ?startkey="foo"&endkey="bar" When doing reduces with a start/end key
> its calculating the single reduce value between those values.
> Using the multi-key fetch we're trying to pull back a row for a given
> key, if you don't have a ?group=true then there are no keys to look
> for.
> Paul Davis

I wouldn't mind seeing a JSON definition for queries, so that all view
queries (not just multi-key) could be posted to the view (and with
temp views). If we had something like this:


we could allow POSTing arrays of these, for a series of view queries
in on request. I know some people who really want to see this, writing
this could make you a hero.

This would clean up the key="foo" vs keys : ["foo"] disparity, and
give a bunch more flexibility about multi-range queries.


Chris Anderson

View raw message