Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 21090 invoked from network); 6 Feb 2011 22:38:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Feb 2011 22:38:12 -0000 Received: (qmail 14345 invoked by uid 500); 6 Feb 2011 22:38:10 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 14283 invoked by uid 500); 6 Feb 2011 22:38:09 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 14273 invoked by uid 99); 6 Feb 2011 22:38:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Feb 2011 22:38:09 +0000 X-ASF-Spam-Status: No, hits=1.8 required=5.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of robert.newson@gmail.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Feb 2011 22:38:04 +0000 Received: by bwz4 with SMTP id 4so4254151bwz.11 for ; Sun, 06 Feb 2011 14:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=rl2nUmnYIM9hYTLMIQZGKFjHDBk/a7uCBoh4ZxXldOI=; b=j6YPUUorvDPVGQJP8vmC0CHepTrGXTgqN+H/H0xB2F1dNfM/YKs2ZnfI47cJ1d+oZP N3MGJbIZLXvp6pwOrFtKZp6favn1PF1QGChMwVPwN5ikCzd8h+e0wKv74KqgixsQAIDf Y5qRHDftfuihKponZkdBS+NPsPtEfR6mJn47g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=vp78nNJBlEJJQOt4HFIw7fSIB7eHZ/CQ0DtjUmhDpuZMKuvuHwKJg1NE5N+WwxASv9 0JNrhEz5y3eGgrLtXkryeq7TqzcUo3PoO+lz5uu3AlmE+zYK+eKolhJgFyjfDA23p3ha IfY4KYRjWqRaDJKvx6rFNhWrOIFKMmSk9qW/k= MIME-Version: 1.0 Received: by 10.204.52.134 with SMTP id i6mr8265891bkg.36.1297031860825; Sun, 06 Feb 2011 14:37:40 -0800 (PST) Received: by 10.204.113.146 with HTTP; Sun, 6 Feb 2011 14:37:40 -0800 (PST) In-Reply-To: References: Date: Sun, 6 Feb 2011 22:37:40 +0000 Message-ID: Subject: Re: date range querying From: Robert Newson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Within couchdb itself, I think you'd have to do as Nils suggested; for (day =3D startDate; day < endDate; day=3D 1 day) { emit(day, null); } then ?key=3D Or you could use couchdb-lucene, index startDate and endDate as dates, query with ?q=3DstartDate:[day TO maxdate]&endDate:[mindate TO day] where 'date' is the date you are searching for. B. On Sun, Feb 6, 2011 at 10:31 PM, Nils Breunese wrote: > You could emit a view index entry for every day in the date range of a do= cument? This could become inefficient storage-wise if you have large date r= anges. > > 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 emi= t method takes two arguments AFAIK: a key and a value. You seem to be emitt= ing a single value? > > Nils. > ________________________________________ > Van: Warner Onstine [warnero@gmail.com] > Verzonden: zondag 6 februari 2011 22:57 > Aan: user@couchdb.apache.org > 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: > =A0 =A0 =A0 var startDate =3D new Date(doc.startDate); > =A0 =A0 =A0 =A0var endDate =3D new Date(doc.endDate); > =A0 =A0 =A0 =A0var startYear =3D startDate.getFullYear(); > =A0 =A0 =A0 =A0var startMonth =3D startDate.getMonth(); > =A0 =A0 =A0 =A0var startDay =3D startDate.getDate(); > =A0 =A0 =A0 =A0var endYear =3D endDate.getFullYear(); > =A0 =A0 =A0 =A0var endMonth =3D endDate.getMonth(); > =A0 =A0 =A0 =A0var endDay =3D endDate.getDate(); > =A0 =A0 =A0 =A0emit([ > =A0 =A0 =A0 =A0 =A0 =A0startYear, > =A0 =A0 =A0 =A0 =A0 =A0startMonth, > =A0 =A0 =A0 =A0 =A0 =A0startDay, > =A0 =A0 =A0 =A0 =A0 =A0endYear, > =A0 =A0 =A0 =A0 =A0 =A0endMonth, > =A0 =A0 =A0 =A0 =A0 =A0endDay > =A0 =A0 =A0 =A0]); > > 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 > ------------------------------------------------------------------------ > =A0VPRO =A0 www.vpro.nl > ------------------------------------------------------------------------ >