Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 40567 invoked from network); 12 Feb 2011 15:00:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Feb 2011 15:00:50 -0000 Received: (qmail 93606 invoked by uid 500); 12 Feb 2011 15:00:49 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 93320 invoked by uid 500); 12 Feb 2011 15:00:46 -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 93312 invoked by uid 99); 12 Feb 2011 15:00:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Feb 2011 15:00:45 +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 (nike.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; Sat, 12 Feb 2011 15:00:39 +0000 Received: by bwz4 with SMTP id 4so3918233bwz.11 for ; Sat, 12 Feb 2011 07:00:18 -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=Rqc5QKht8q481GSWeeXwhu8MTJhTmE6Z+8EUU9uCmM0=; b=rRsJU2anKnjEAIKYQ+JGEKWDG5iOh1pkq/VkOs1iIUyo9cPW9dd0+5zOTp3usfKkuw AiySyd0ZSxcny3+Mcegp3zgXPxwa9/6owZz4l4u3HRTMvgYj/XitzqrvFS6Kqk+9SiAo o0dv642agbbvkYv+SvvbzgYFcHXZ6bwqmi7Sk= 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=poS++hqsxPI9sqzo7TgDT5ep+B5uqr7oR4T2yeOjXUvSbdoj16rWZJJylIMsjx+vRa f2NRvKz9nrtYhlDz7AywlRtsXJOOlv458rU0OXzR3tCG0r+QjLVNkCxX3Hjm3ClTMGAD hwpg2zBZGmTKQk1zgaUd1szLP6Pjx8U8yby5k= MIME-Version: 1.0 Received: by 10.204.140.70 with SMTP id h6mr4231886bku.117.1297522817505; Sat, 12 Feb 2011 07:00:17 -0800 (PST) Received: by 10.204.113.146 with HTTP; Sat, 12 Feb 2011 07:00:17 -0800 (PST) In-Reply-To: References: Date: Sat, 12 Feb 2011 15:00:17 +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 X-Virus-Checked: Checked by ClamAV on apache.org day=3D1 day was a typo *and* pseudocode. I mean simply that you should increment 'day' by '1 whole day' in the loop. let's assume day is an integral value from some epoch (0 meaning jan 1 1970, 1 meaning jan 2 1970, and so on). for (day=3DstartDay; day wrote: > I tried that with no success (in fact it completely borked all views > for that document type and had to delete it to get things working > again. I may try and monkey around with these two scripts again to see > what I did wrong. > > It really didn't like > day=3D 1 day > > and honestly I'm not even sure what that's supposed to do. > > Thanks for the suggestions, I'll let you know if I figure it out. But > I am seriously thinking about using ElasticSearch to make it a more > robust searching solution (I have a lot of searching coming up soon). > > -warner > > On Sun, Feb 6, 2011 at 3:37 PM, Robert Newson w= rote: >> Within couchdb itself, I think you'd have to do as Nils suggested; >> >> for (day =3D startDate; day < endDate; day=3D 1 day) { >> =A0emit(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 wrot= e: >>> 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 wha= t way are you querying your view? I have to admit I have no idea how I coul= d get the information you're looking for from that complex key. Also, the e= mit method takes two arguments AFAIK: a key and a value. You seem to be emi= tting 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 >>> -----------------------------------------------------------------------= - >>> >> >