67 lines
2.7 KiB
Plaintext
67 lines
2.7 KiB
Plaintext
MBOX-Line: From markrcrispin at panda.com Thu Jan 29 12:08:17 2009
|
|
To: imap-protocol@u.washington.edu
|
|
From: Mark Crispin <markrcrispin@panda.com>
|
|
Date: Fri Jun 8 12:34:42 2018
|
|
Subject: [Imap-protocol] SEARCH OR question
|
|
In-Reply-To: <4981FBC7.9040509@sun.com>
|
|
References: <4981FBC7.9040509@sun.com>
|
|
Message-ID: <alpine.OSX.2.00.0901291151270.283@hsinghsing.panda.com>
|
|
|
|
On Thu, 29 Jan 2009, Bill Shannon wrote:
|
|
> What's the correct syntax to do a SEARCH for an OR of three terms?
|
|
> I've been using:
|
|
>
|
|
> SEARCH OR OR HEADER Message-ID id1 HEADER Message-ID id2 HEADER Message-ID id3
|
|
|
|
This results in a positive for any message with header "Message-ID" that
|
|
contains either "id1", "id2", or "id3". The order of evaluation isn't
|
|
important, although I many servers would look for id1 first, then id2,
|
|
then id3 (evaluating left-to-right and innermost first).
|
|
|
|
> SEARCH OR (HEADER Message-ID id1 HEADER Message-ID id2 HEADER Message-ID id3)
|
|
|
|
No. That is a syntax error, since only one expression (the AND of the
|
|
three HEADER searches) is passed to OR.
|
|
|
|
> SEARCH OR HEADER Message-ID id1 (HEADER Message-ID id2 HEADER Message-ID id3)
|
|
|
|
That will OR the id1 match with the AND of the id2/id3 searches. That
|
|
differs from
|
|
|
|
SEARCH OR HEADER Message-ID id1 HEADER Message-ID id2 HEADER Message-ID id3
|
|
|
|
which will OR the id1 and ID2 search, then AND that with the id3 search.
|
|
|
|
This sounds like there is an evaluation order dependency, but there isn't.
|
|
Criteria in IMAP are ANDed. OR is a single criterion that takes two
|
|
criteria as arguments. Thus,
|
|
OR HEADER Message-ID id1 HEADER Message-ID id2
|
|
is a single criterion.
|
|
|
|
However, the human mind quickly boggles at the complexities, hence the
|
|
provision of parentheses in the syntax. Parentheses convert multiple
|
|
(ANDed) criteria into a single criteria. Consider:
|
|
SEARCH OR (FROM Bill TO Jane) (FROM Jane TO Bill)
|
|
which will match all messages that are between Bill and Jane directly, but
|
|
not those from other individuals or those in which the other is merely a
|
|
cc.
|
|
|
|
> Assuming the first syntax at the top is correct, it appears that Exchange
|
|
> 2003 fails with more than two terms in OR. Anyone know if that's a known
|
|
> bug? I can't find anything in the Microsoft knowledge base.
|
|
|
|
Are you sure that it's Exchange 2003? AFAIK, 2003 was the last working
|
|
version of Exchange and I recall it as working well.
|
|
|
|
Newer versions of Exchange certainly do suck in their implementation of
|
|
SEARCH (and other aspects of IMAP). Not coincidentally, the departure
|
|
from the Exchange team of the IMAP-clueful guys at Microsoft was at about
|
|
the same time... :-(
|
|
|
|
-- Mark --
|
|
|
|
http://panda.com/mrc
|
|
Democracy is two wolves and a sheep deciding what to eat for lunch.
|
|
Liberty is a well-armed sheep contesting the vote.
|
|
|