incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Viacheslav Seledkin <viacheslav.seled...@avicomp.com>
Subject How to create view to count number of unique values from documents .... ?
Date Thu, 15 Jan 2009 10:56:56 GMT
After reading all docs I think it is not trivial. The task itself: I 
have documents with fields
..............
doc(N) = {
...
tag:"y",
tag:"o",
tag:"b",
tag:"b",
tag:"v",
tag:"r",
............
}

doc(N+1) = {
...
tag:"a",
tag:"b",
tag:"t",
tag:"b",
tag:"u",
tag:"r",
...
}

doc(N+2)= {
...
tag:"t",
tag:"m",
tag:"i",
tag:"b",
tag:"l",
tag:"z",
...........
}
.............
and so on...

How to create a view that allows to get number of unique tags throught 
various range of some keys. 

i.e
..
emit(keyN1,"y") - from document doc(N)
emit(keyN2,"o") - from document doc(N)
....
emit(key(N+2),"z") - from document doc(N+2)
..

and view request
http://.../_view/?startkey=someStartKey&endkey=someEndKey
gives me something like

{"rows":[{"key":null,"value":12}]}????

Of course i can use documented example with emit("y",1) and  
reduce()(return sum(values);) and count the number of rows returned to 
the client but i have many thousands of tags and it is not effective. 
Any help appreciated.


Mime
View raw message