You could emit a view index entry for every day in the date range of a 
document? This could become inefficient storage-wise if you have large date 
ranges.

What exactly "starts returning records that don't match at all"? In what way 
are you querying your view? I have to admit I have no idea how I could get the 
information you're looking for from that complex key. Also, the emit method 
takes two arguments AFAIK: a key and a value. You seem to be emitting a single 
value?

Nils.
________________________________________
Van: Warner Onstine [[email protected]]
Verzonden: zondag 6 februari 2011 22:57
Aan: [email protected]
Onderwerp: date range querying

Ok, been banging my head against this for a while and having no luck
figuring out the logical way to do this (other than installing
ElasticSearch - which I'll be doing in the near future).

I have records that have startDate and endDate ranges. I want to query
the view based on today's date. Say I have a record that has a start
date of 1/31/2011 and an end date of 2/13/2011 and I want to find out
which records fall within today's date.

In other words
1/31/2011 < 2/6/2011 < 2/13/2011

How in the world do I do that? I've been trying something like this:
       var startDate = new Date(doc.startDate);
        var endDate = new Date(doc.endDate);
        var startYear = startDate.getFullYear();
        var startMonth = startDate.getMonth();
        var startDay = startDate.getDate();
        var endYear = endDate.getFullYear();
        var endMonth = endDate.getMonth();
        var endDay = endDate.getDate();
        emit([
            startYear,
            startMonth,
            startDay,
            endYear,
            endMonth,
            endDay
        ]);

But as soon as I add in the endYear variable it goes wonky and starts
returning records that don't match at all. Any help is greatly
appreciated.

-warner
------------------------------------------------------------------------
 VPRO   www.vpro.nl
------------------------------------------------------------------------

Reply via email to