incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kiran Lonikar <kloni...@yahoo.com>
Subject Re: Getting map results in key --> array of values format
Date Tue, 30 Aug 2011 17:46:12 GMT
Using _count-reduce on the same view is a good idea to know how many values for the key are
there in the view.

The reason I want to use limit is to retrieve a small number of keys at a time and perform
reduce on those keys on another host. For this, I would prefer to get all values of a key
in one shot rather than getting them in multiple chunks, thus having to run reduce multiple
times for the same key.

Thanks.
Kiran



________________________________
From: Zachary Zolton <zachary.zolton@gmail.com>
To: user@couchdb.apache.org; Kiran Lonikar <klonikar@yahoo.com>
Sent: Tuesday, 30 August 2011 7:18 PM
Subject: Re: Getting map results in key --> array of values format

Oh, I meant _count not _sum, to count up the number of values per key.

On Tue, Aug 30, 2011 at 8:46 AM, Zachary Zolton
<zachary.zolton@gmail.com> wrote:
> Kiran,
>
> Using a list function is the appropriate tool for reformatting the
> output of a view query.
>
> If you don't want to chop off some values, then why are you using limit? (^_-
>
> Perhaps, you could query this same view with a _sum reduce? That way
> you can know how many values would come back per key.
>
> I think we'll need to hear more to help you here.
>
>
> Cheers,
>
> Zach
>
> On Tue, Aug 30, 2011 at 1:17 AM, Kiran Lonikar <klonikar@yahoo.com> wrote:
>> Hi,
>>
>> I just started using couchdb. I have the following question:
>> Currently the results of map are returned in the following format:
>>
>> {
>> "total_rows": 3,
>> "offset": 0,
>> "rows": [
>> {
>> "key": "key1",
>> "id": "doc-id1",
>> "value": "value1"
>> },
>>
>> {
>> "key": "key1",
>> "id": "doc-id2",
>> "value": "value2"
>> },
>>
>> {
>> "key": "key2",
>> "id": "doc-id3",
>> "value": "value3"
>> }
>> ]
>> }
>>
>> Is it possible to condense the same "key" rows and get the results in the format
below:
>>
>> {
>> "rows": [
>> {
>> "key": "key1",
>> "value": ["value1", value2]
>> },
>>
>> {
>> "key": "key2",
>> "value": "[value3]"
>> }
>> ]
>> }
>>
>> I think I will have to use a list function to format the view results since there
are no view parameters to do this and also since I do not want to use the reduce function.
>>
>> The list function is complicated by the fact that if I use limit and startkey parameters
of the view, it is likely that limit may chop off some values for the last key and those values
will not appear in the list output.
>>
>> Instead, I would like to know if there is any option where couchdb view retrieval
itself can be changed to retrieve the output in the way I want.
>>
>> Thanks,
>> Kiran
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message