incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Mills <>
Subject Re: Views
Date Sat, 26 Apr 2008 18:50:19 GMT
I read both those links.  I understand what they are trying to do, but  
I'm not really trying to collate two document types.

Maybe I missing something.  When you create a view, does it create  
indexes for attributes in the database?  When you add new documents,  
do they automatically create the index for the attributes for the view?

Also, can I call my view with soemthing like ? 
startkey=['20080403t000000', 1234]&endkey=['20080405t235959', 1234] to

	if(doc.type == "hello"){
		map([, doc.number], doc);

Then, through the magic of couchdb, I'll only get back those documents  
between the April 3rd and 5th whose attribute number=1234?

Will couchdb only search through records that match the key? or will  
it need to go through all documents every time I call the view?

To get nerdy, I want my views to find records in O(log n) not O(n).



On Apr 26, 2008, at 1:02 AM, Chris Anderson wrote:

> Anthony,
> is the way to accomplish
> tasks like that.
> Christopher Lenz has a write-up of how to use view collation to sort
> views, achieving comments grouped by parent blog post.
> In your case you could index a view with date and type, like this
> [type, date]
> and then if you had say 5 types you'd do 5 GET queries against the
> database, each one fetching only the documents for that day.
> View collation is one of my favorite things about CouchDB. I'm excited
> about reduce, because from what I understand, you could use it to
> lower this to 1 GET, if that's important to you.
> enjoy,
> Chris
> On Fri, Apr 25, 2008 at 9:34 PM, Anthony Mills  
> <> wrote:
>> I read most of the documentation, wiki and blogs, but I still do  
>> not see how
>> to accomplish a certain scenario.  Hopefully I can describe it  
>> adiquitely.
>> Lets say I have 1,000,000 documents [all of the same "type"] with a  
>> date
>> attribute.  Lets say I want to pick a subset of those documents.   
>> How can I
>> pick those documents of one type that fall on one day?  Will I need  
>> to get
>> all 1,000,000 documents?  What if I want all documents of one type  
>> on one
>> day that match another attribute?
>> I pretty sure this is what map/reduce will help with, but is there  
>> a way to
>> do this now?  Can you use more documents to build date relations?
>> Also, can you pass more variables than just key to

View raw message