incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manolo Padron Martinez <manol...@gmail.com>
Subject Re: [user] Obtaining unique values from a view
Date Tue, 03 Mar 2009 13:58:32 GMT
> I believe this has been covered in this thread:
> http://markmail.org/thread/lwqfwlscrvilwm34
>
> but I think a totally satisfactory answer was not found.
>

Thanks that works for me.


>
> Wout.
>
>
> On Mar 3, 2009, at 2:27 PM, Manolo Padron Martinez wrote:
>
>  Hi:
>>
>> I'm really a newbie, and I have a newbie problem (and maybe a miss
>> conception of the way to work with couch).
>> I have a lot of documents with this form (that represents experiments with
>> any number of conditions, so X and Y could be only X or even X,Y,Z...)
>>
>> {
>>  "Experiment":"something",
>>  "Conditions":
>>      {
>>        "X":3,
>>        "Y":2
>>      }
>> }
>>
>> And I have a view like:
>> MAP:
>>
>> function(doc) {
>>  if (doc.Experiment)
>>  for (i in doc.Conditions){
>>      emit(doc.Experiment, i);
>>  }
>> }
>>
>> REDUCE:
>>
>> function(key,values)
>> {
>> return values;
>> }
>>
>> When I launch the view I get this:
>>
>>
>> {"rows":[{"key":"Something","value":["X","Y"]},{"key":"Something2","value":["X","Y","X","Y","X","Y","Z","X","Y","X","Y","X","Y","Z"]}]}
>>
>>
>>
>> I would like to get what are the conditions for every experiment grouped
>> by
>> experiment without repetitions (I mean something like)
>>
>>
>> {"rows":[{"key":"Something","value":["X","Y"]},{"key":"Something2","value":["X","Y","Z"]}]}
>>
>>
>> Anyone could help me?
>>
>> Regards from Canary Island
>>
>> Manuel Padron Martinez
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message