Reputation: 666
I have two IMAP SEARCH commands. Can anyone please tell me which one of these is formatted correctly, or if indeed they both are:
Search A:
UID SEARCH NOT DELETED (OR FROM "eBay" (OR SUBJECT "eBay" (OR TO "eBay" (OR CC "eBay" BODY "eBay"))))
Search B:
UID SEARCH (OR FROM "eBay" (OR SUBJECT "eBay" (OR TO "eBay" (OR CC "eBay" BODY "eBay")))) NOT DELETED
One returns the correct results from my inbox, but the other does not. I'm trying to work out if my mail server software is at fault, or the client issuing the command.
Thanks
Upvotes: 3
Views: 5140
Reputation: 1207
These searches may be syntactically the same, but they could have quite different performance.
There are 2 main search clauses, and one of these is actually a search on a bunch of text fields and the body. The other is a very inexpensive flag check (for undeleted messages).
If the server performing the search checks the /Deleted flag first, then it can potentially save itself a lot of work checking the other text fields (especially the body).
A server that naively checks the search clauses in the order given, would be better doing a flag check first (the top search). If there are no deleted messages in the folder it won't make much difference, since the flag check is likely insignificant in terms of cost. But if there are a lot of deleted messages, then the second form of the search could be a lot more expensive, depending on whether the server is smart enough to do cheap tests first.
Which server is it?
Upvotes: 1
Reputation: 9685
Those are equivalent ways to express the same search. Both are correct and any correct server should return the same set of messages for both searches.
Somewhat simplified, the following two are different ways to express "tell me which messages have not been read and are about subject ebay":
s1 uid search subject "ebay" unseen
s2 uid search unseen subject "ebay"
A and B is the same as B and A.
Upvotes: 6