Re: [PATCH v3 6/9] lib: add date range query support
authorJani Nikula <jani@nikula.org>
Thu, 13 Sep 2012 13:33:12 +0000 (15:33 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:30 +0000 (09:49 -0800)
40/601210abc1f1630b9b3de3594645492e5c53d2 [new file with mode: 0644]

diff --git a/40/601210abc1f1630b9b3de3594645492e5c53d2 b/40/601210abc1f1630b9b3de3594645492e5c53d2
new file mode 100644 (file)
index 0000000..072d66e
--- /dev/null
@@ -0,0 +1,125 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 36CD4431FAF\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Sep 2012 06:33:30 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id Hgf-cwZCkxKQ for <notmuch@notmuchmail.org>;\r
+       Thu, 13 Sep 2012 06:33:29 -0700 (PDT)\r
+Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com\r
+       [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 726BD431FAE\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Sep 2012 06:33:29 -0700 (PDT)\r
+Received: by qcpx40 with SMTP id x40so2227693qcp.26\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Sep 2012 06:33:26 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type:x-gm-message-state;\r
+       bh=2RbYP5a1EjoMxdHLUT4oQhORDduM+poqTyi2LUM/tU4=;\r
+       b=GUUbSX624zM/GTKCAlCWz5xofLzcZikG5eYyZsindt6QYf8NLwo/ue1na+XmThavMg\r
+       1nBEUQ/4+SEmizQvSab4STL8WaLg1+ub9AIl1zHkUigYUKPvsNk6wdBFldUMmDLN8uzS\r
+       lEvgmV8EXPjgVmim4Z26Ni+m7QUH+db6mrj0dRvXW+ndbqMfDbS7BZaZPp+whgBO1po5\r
+       TDYFr7tsVQ/dfIaD4pzXAo81q2DVnVF1bVl9gB4raLA94896XPz2RavmnjY1uyYbDmqV\r
+       W7LeDeqXov+omzJtFVQSu2m6dWkpcEbToOL0iY36usiuGmml38uUxTSb32RICyI4zOdc\r
+       i8gA==\r
+Received: by 10.224.70.141 with SMTP id d13mr5464101qaj.99.1347543206662;\r
+       Thu, 13 Sep 2012 06:33:26 -0700 (PDT)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+       by mx.google.com with ESMTPS id\r
+       dg10sm14046837qab.12.2012.09.13.06.33.21\r
+       (version=SSLv3 cipher=OTHER); Thu, 13 Sep 2012 06:33:25 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>, Michal Nazarewicz <mina86@mina86.com>,\r
+       notmuch@notmuchmail.org, David Bremner <david@tethera.net>\r
+Subject: Re: [PATCH v3 6/9] lib: add date range query support\r
+In-Reply-To: <m2r4q6jgz5.fsf@guru.guru-group.fi>\r
+References: <cover.1347484177.git.jani@nikula.org>\r
+       <532340d05ea748518c021048900bb83149e04e88.1347484177.git.jani@nikula.org>\r
+       <xa1tsjamdvj6.fsf@mina86.com> <m2r4q6jgz5.fsf@guru.guru-group.fi>\r
+User-Agent: Notmuch/0.14+43~gd23e654 (http://notmuchmail.org) Emacs/23.2.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Thu, 13 Sep 2012 15:33:12 +0200\r
+Message-ID: <874nn2rqsn.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Gm-Message-State:\r
+ ALoCoQnVZ5+FC71tp3Pp4CFMccijjbz8nMfBOR5xm4sD9fDh8qTR0bX4xpJMqp9Gfqtig2eWpjvS\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 13 Sep 2012 13:33:30 -0000\r
+\r
+On Thu, 13 Sep 2012, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
+> On Thu, Sep 13 2012, Michal Nazarewicz <mina86@mina86.com> wrote:\r
+>\r
+>> On Wed, Sep 12 2012, Jani Nikula wrote:\r
+>>> Add a custom value range processor to enable date and time searches of\r
+>>> the form date:since..until, where "since" and "until" are expressions\r
+>>> understood by the previously added date/time parser, to restrict the\r
+>>> results to messages within a particular time range (based on the Date:\r
+>>> header).\r
+>>>\r
+>>> If "since" or "until" describes date/time at an accuracy of days or\r
+>>> less, the values are rounded according to the accuracy, towards past\r
+>>> for "since" and towards future for "until". For example,\r
+>>> date:november..yesterday would match from the beginning of November\r
+>>> until the end of yesterday. Expressions such as date:today..today\r
+>>> means since the beginning of today until the end of today.\r
+>>\r
+>> IMO this is totally unintuitive and not how the range should work.\r
+>> date:foo..bar should return messages whose date >= foo and < bar.  So\r
+>> for instance date:november..yesterday should return messages whose date\r
+>> is > 2012/11/01 00:00:00 and < 2012/09/12 00:00:00.  So to get\r
+>> yesterdays messages one would do: date:yesterday..today.\r
+>\r
+>\r
+> I find yesterday..yesterday to return whole yesterday's messages more\r
+> intuitive than that returning zero messages and requiring yesterday..today\r
+> to see messages sent yesterday. However, I've noticed that range\r
+> described as -1day..-1day (if that syntax is/were supported)\r
+> that would be a bit confusing (In yesterday's case I think the length\r
+> of 'yesterday' is 24h, but in '-1day' the lenght is one second\r
+> (or something))\r
+\r
+"yesterday" equals "1 day", so you can use date:yesterday..yesterday and\r
+date:1d..1d interchangeably.\r
+\r
+> Anyway, this just emphasizes that this is confusing matter; we need\r
+> a good idiom to comprehend this issue...\r
+\r
+I find "since" rounding towards past and "until" rounding towards future\r
+a very simple rule. But YMMV.\r
+\r
+One technical aspect is preparing for handling date:expr *without*\r
+range, for example date:yesterday, in the future (this is currently not\r
+supported by xapian). Intuitively that should mean all messages received\r
+yesterday. Because the date parser does not see the range (or lack of\r
+it) at all (and this is very much by design), the glue layer in notmuch\r
+lib between the parser and xapian should handle it gracefully, with no\r
+understanding of expr itself. The obvious and simple way to handle that\r
+is to just duplicate expr on both sides of the range, and date:yesterday\r
+would equal date:yesterday..yesterday, in a way that is very simple to\r
+implement and explain to users.\r
+\r
+\r
+BR,\r
+Jani.\r