incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramanadham, Radhika" <radhika.ramanad...@emc.com>
Subject RE: Question on views
Date Mon, 09 Jun 2014 18:05:51 GMT
Thanks.
I think I can change the keys -> key2, key1. 
What would be the query?

The below throws me an error.

http://127.0.0.1:5984/longevity/_design/perfstats/_view/by_server?key=[key2,_]

example:

http://127.0.0.1:5984/longevity/_design/perfstats/_view/by_server?key=[" lglod025.lss.emc.com",_]

What am I doing wrong?

-----Original Message-----
From: Guilherme Andrade [mailto:g@gandrade.net] 
Sent: Monday, June 09, 2014 12:57 PM
To: user@couchdb.apache.org
Subject: Re: Question on views

Unfortunately there's no performant way to do it like that, views have strict ordering and
ranges/subranges are only possible within the confinements of the composite key order.

One way to do it is to have a second view that emits keys in reverse ([key2, key1]); then
you may do a range query based on [key2, _].

Cheers,

On 09-06-2014 17:36, Ramanadham, Radhika wrote:
> Hi,
>
> I have a view which has 2 keys- key1 and key2:
>
> "by_server": {
>                 "map": "function(doc) { if ((doc.type == 'performance_stats'))  emit([key1,
key2],{ 'Start_time':doc.start_time ,'CPU': doc.CPU, 'Memory': doc.Memory, 'FileSystem':doc.FileSystem
}) }"
>  },
>
>
> If I want to query the view where I need all the rows for key2 and key1 being anything,
how do I do it?
>
> Let's say my data is->
>
> {"id":"server_lglod025.lss.emc.com_2014-06-09_10:24:18","key":["lglod0
> 25.lss.emc.com","SRMSuite_3.0.2_test1"],"value":{"Start_time":"2014-06
> -09 09:00:00","CPU":12,"Memory":98,"FileSystem":96}},
> {"id":"server_lglod093.lss.emc.com_2014-06-09_11:24:18","key":["lglod0
> 93.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06
> -09 10:00:00","CPU":12,"Memory":98,"FileSystem":97}},
> {"id":"server_lglod174.lss.emc.com_2014-06-04_14:01:44","key":["lglod1
> 74.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06
> -04 10:00:00","CPU":67,"Memory":97,"FileSystem":17}},
>
> I only want the below 2 rows who have a key2 = SRMSuite_3.0.2_test2, how do I do it?
>
> {"id":"server_lglod093.lss.emc.com_2014-06-09_11:24:18","key":["lglod0
> 93.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06
> -09 10:00:00","CPU":12,"Memory":98,"FileSystem":97}},
> {"id":"server_lglod174.lss.emc.com_2014-06-04_14:01:44","key":["lglod1
> 74.lss.emc.com","SRMSuite_3.0.2_test2"],"value":{"Start_time":"2014-06
> -04 10:00:00","CPU":67,"Memory":97,"FileSystem":17}},
>
> Thanks,
> Radhika
>

--
Guilherme Andrade

PGP fingerprint: 1968 5252 3901 B40F ED8A  D67A 9330 79B1 35CB 8191



Mime
View raw message