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":["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
>
--
Guilherme Andrade
PGP fingerprint: 1968 5252 3901 B40F ED8A D67A 9330 79B1 35CB 8191
signature.asc
Description: OpenPGP digital signature
