couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Rothbucher <sebastianrothbuc...@googlemail.com>
Subject Re: Question on views
Date Mon, 09 Jun 2014 17:05:10 GMT
Hi,

unless you emit sth like [key2, key1] I don't think you can find by key2 for any key1. Reason
being the sort of the underlying b+ tree. However, you can emit several times per doc.

List functions to filter ex post yield crappy performance, so I'd never do that. Sticking
to several emits will rather do the trick I think.

Good luck
     Sebastian

Von meinem iPhone gesendet

> Am 09.06.2014 um 18:36 schrieb "Ramanadham, Radhika" <radhika.ramanadham@emc.com>:
> 
> 
> 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":["lglod025.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":["lglod093.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":["lglod174.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":["lglod093.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":["lglod174.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

Mime
View raw message