[PATCH v3 6/9] lib: add date range query support

Jani Nikula jani at nikula.org
Thu Sep 13 06:33:12 PDT 2012


On Thu, 13 Sep 2012, Tomi Ollila <tomi.ollila at iki.fi> wrote:
> On Thu, Sep 13 2012, Michal Nazarewicz <mina86 at mina86.com> wrote:
>
>> On Wed, Sep 12 2012, Jani Nikula wrote:
>>> Add a custom value range processor to enable date and time searches of
>>> the form date:since..until, where "since" and "until" are expressions
>>> understood by the previously added date/time parser, to restrict the
>>> results to messages within a particular time range (based on the Date:
>>> header).
>>>
>>> If "since" or "until" describes date/time at an accuracy of days or
>>> less, the values are rounded according to the accuracy, towards past
>>> for "since" and towards future for "until". For example,
>>> date:november..yesterday would match from the beginning of November
>>> until the end of yesterday. Expressions such as date:today..today
>>> means since the beginning of today until the end of today.
>>
>> IMO this is totally unintuitive and not how the range should work.
>> date:foo..bar should return messages whose date >= foo and < bar.  So
>> for instance date:november..yesterday should return messages whose date
>> is > 2012/11/01 00:00:00 and < 2012/09/12 00:00:00.  So to get
>> yesterdays messages one would do: date:yesterday..today.
>
>
> I find yesterday..yesterday to return whole yesterday's messages more
> intuitive than that returning zero messages and requiring yesterday..today
> to see messages sent yesterday. However, I've noticed that range
> described as -1day..-1day (if that syntax is/were supported)
> that would be a bit confusing (In yesterday's case I think the length
> of 'yesterday' is 24h, but in '-1day' the lenght is one second
> (or something))

"yesterday" equals "1 day", so you can use date:yesterday..yesterday and
date:1d..1d interchangeably.

> Anyway, this just emphasizes that this is confusing matter; we need
> a good idiom to comprehend this issue...

I find "since" rounding towards past and "until" rounding towards future
a very simple rule. But YMMV.

One technical aspect is preparing for handling date:expr *without*
range, for example date:yesterday, in the future (this is currently not
supported by xapian). Intuitively that should mean all messages received
yesterday. Because the date parser does not see the range (or lack of
it) at all (and this is very much by design), the glue layer in notmuch
lib between the parser and xapian should handle it gracefully, with no
understanding of expr itself. The obvious and simple way to handle that
is to just duplicate expr on both sides of the range, and date:yesterday
would equal date:yesterday..yesterday, in a way that is very simple to
implement and explain to users.


BR,
Jani.


More information about the notmuch mailing list