Hi Anthony

You can do it like this:

function(doc){
        if(doc.type == "THETYPE"){
                map(doc.date, doc);
        }
}

Where type is an attribute storing the document type and date is the date attribute. Then you can use a key to get a document from a certain date, or you could use startkey endkey to get a range of documents

If you want them to match another attribute as well you could either rewrite it like this:

function(doc){
        if(doc.type == "THETYPE" && doc.other_attribute == "some_value"){
                map(doc.date, doc);
        }
}

Or using view collation you could write it like this:

function(doc){
        if(doc.type == "THETYPE" && doc.other_attribute == "some_value"){
                map([doc.date,true], doc);
        }
        if(doc.type == "THETYPE" && doc.other_attribute != "some_value"){
                map([doc.date,false], doc);
        }
        if(doc.type == "THETYPE"){
                map(doc.date, doc);
        }
}

then you can use keys like [date, true] to get the documents where the other attribute is true, and [date, false] to get the documents where the value is not true, or just date to get documents regardless of the state of the other attribute...

Hope that helps.

Best regards
Sebastian



On Apr 26, 2008, at 1:34 AM, 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 variab

Reply via email to