Internet Draft A. Melnikov Document: draft-melnikov-imap-search-ret Isode Ltd Expires: April 2006 D. Cridland Inventure Systems Ltd October 2005 IMAP4 extension to SEARCH command for controlling what kind of information is returned draft-melnikov-imap-search-ret-02 Status of this Memo By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet- Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. A revised version of this draft document will be submitted to the RFC editor as a Standard Track RFC for the Internet Community. Discussion and suggestions for improvement are requested, and should be sent to email@example.com and/or firstname.lastname@example.org. Distribution of this memo is unlimited. Abstract This document extends SEARCH and UID SEARCH commands with result specifier, which can control what kind of information is returned. Several result specifiers are defined: minimal value, maximal value, all found messages and number of found messages. A new untagged response ESEARCH is also specified. Table of Contents 1. Conventions Used in this Document 2 2. Introduction 3 3. IMAP Protocol Changes 3 3.1 SEARCH/UID SEARCH Commands 3 4. Formal Syntax 6 5. Security Considerations 7 6. IANA Considerations 7 7. References 7 7.1 Normative References 7 7.2 Informative References 8 8. Acknowledgments 8 9. Author's Addresses 8 10. Full Copyright Statement 8 11. Intellectual Property 9 12. Appendix A. Editorial. 9 12.1 Change Log 9 12.2 Open Issues for Discussion 10 1. Conventions Used in this Document In examples, "C:" and "S:" indicate lines sent by the client and server respectively. The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and "MAY" in this document are to be interpreted as defined in "Key words for use in RFCs to Indicate Requirement Levels" [KEYWORDS]. <<Editorial comments and questions are enclosed like this>> 2. Introduction This document extends SEARCH and UID SEARCH commands with result specifiers (also known as return options), which can control what kind of information is returned. Several result specifiers are defined: minimal value, maximal value, all found messages and number of found messages. A new response ESEARCH is also specified, which replaces the SEARCH response. The extension described in this document allows clients to get results for SEARCH requests in a more convenient form, while also saving bandwidth required to transport the results, for example finding the first unseen message or returning the number of unseen or deleted messages. Also, when a single MIN or a single MAX return option is specified, servers can optimize execution of SEARCHes. 3. IMAP Protocol Changes 3.1 SEARCH/UID SEARCH Commands Arguments: OPTIONAL result specifier OPTIONAL [CHARSET] specification searching criteria (one or more) Responses: REQUIRED untagged response: SEARCH or ESEARCH Result: OK - search completed NO - search error: can't search that [CHARSET] or criteria BAD - command unknown or arguments invalid This section updates definition of the SEARCH command described in section 6.4.4 of [IMAP4]. The SEARCH/UID SEARCH command is extended to allow for result options. This document defines 4 search result options: MIN Return the lowest message number/UID that satisfies the SEARCH criteria. If the SEARCH results in no matches, the server MUST NOT include the MIN result option in the ESEARCH response, however it still MUST send the ESEARCH response. MAX Return the highest message number/UID that satisfies the SEARCH criteria. If the SEARCH results in no matches, the server MUST NOT include the MAX result option in the ESEARCH response, however it still MUST send the ESEARCH response. ALL Return all message numbers/UIDs that satisfy the SEARCH criteria. Unlike regular (unextended) SEARCH, the messages are always returned using the sequence-set syntax. A sequence- set representation may be more compact and can be used as is in a subsequent command that accepts sequence-set. Note, the client MUST NOT assume that messages/UIDs will be listed in any particular order. If the SEARCH results in no matches, the server MUST NOT include the ALL result option in the ESEARCH response, however it still MUST send the ESEARCH response. COUNT Return number of the messages that satisfy the SEARCH criteria. This result option MUST always be included in the ESEARCH response. If one or more result option described above is specified, the extended SEARCH command MUST return a single ESEARCH response [IMAPABNF], instead of the SEARCH response. An extended UID SEARCH command MUST cause a ESEARCH response with the UID indicator present. Note that future extensions to this document can allow servers to return multiple ESEARCH responses for a single extended SEARCH command. These extensions will have to describe how results from multiple ESEARCH responses are to be amalgamated. If the list of result options is empty, that requests the server to return an ESEARCH response instead of the SEARCH response. This is equivalent to "(ALL)". Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith" S: * ESEARCH (TAG "A282") MIN 2 COUNT 3 S: A282 OK SEARCH completed Example: C: A283 SEARCH RETURN () FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith" S: * ESEARCH (TAG "A283") ALL 2,10:11 S: A283 OK SEARCH completed The following example demonstrates finding the first unseen message as returned in the UNSEEN response code on a successful SELECT command: Example: C: A284 SEARCH RETURN (MIN) UNSEEN S: * ESEARCH (TAG "A284") MIN 4 S: A284 OK SEARCH completed The following example demonstrates that if the ESEARCH UID indicator is present, all data in the ESEARCH response is referring to UIDs, for example the MIN result specifier will be followed by an UID. Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000 S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800 S: A285 OK SEARCH completed The following example demonstrates returning the number of deleted messages: Example: C: A286 SEARCH RETURN (COUNT) DELETED S: * ESEARCH (TAG "A286") COUNT 15 S: A286 OK SEARCH completed 4. Formal Syntax The following syntax specification uses the Augmented Backus-Naur Form (ABNF) notation as specified in [ABNF]. Non-terminals referenced but not defined below are as defined by [IMAP4] or [IMAPABNF]. Except as noted otherwise, all alphabetic characters are case- insensitive. The use of upper or lower case characters to define token strings is for editorial clarity only. Implementations MUST accept these strings in a case-insensitive fashion. capability =/ "X-DRAFT-I02-ESEARCH" search-return-data = "MIN" SP nz-number / "MAX" SP nz-number / "ALL" SP sequence-set / "COUNT" SP number ;; conforms to the generic ;; search-return-data syntax defined ;; in [IMAPABNF] search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT" ;; conforms to generic search-return-opt ;; syntax defined in [IMAPABNF] <<extend MIN & MAX to allow for parameters?>> <<When the CONDSTORE IMAP extension is also supported <<add reference>> the ABNF is updated as follows: search-return-data =/ "MODSEQ" SP mod-sequence-value >> 5. Security Considerations <<TBD>> 6. IANA Considerations IMAP4 capabilities are registered by publishing a standards track or IESG approved experimental RFC. The registry is currently located at <http://www.iana.org/assignments/imap4-capabilities>. This document defines the X-DRAFT-I02-ESEARCH <<fix before publication>> IMAP capability. IANA is requested to add this capability to the registry. 7. References 7.1 Normative References [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", RFC 2119, March 1997. [IMAP4] Crispin, M., "Internet Message Access Protocol - Version 4rev1", RFC 3501, University of Washington, March 2003. [ABNF] Crocker, D. (Ed.) and P. Overell , "Augmented BNF for Syntax Specifications: ABNF", RFC 4234, October 2005. [IMAPABNF] Melnikov, A., "Collected extensions to IMAP4 ABNF", work in progress, draft-melnikov-imap-ext-abnf-XX.txt. 7.2 Informative References [TRANS-CAPA] Melnikov, A., "Transitional IMAP capabilities", work in progress, draft-melnikov-imap-transitional-capa-XX.txt <<This reference is to be deleted before publication.>> 8. Acknowledgments Thanks to Michael Wener, Arnt Gulbrandsen, Cyrus Daboo, Mark Crispin and Pete Maclean for comments and corrections. 9. Author's Addresses Alexey Melnikov Isode Limited 5 Castle Business Village 36 Station Road Hampton, Middlesex, TW12 2BX UK Email: Alexey.Melnikov@isode.com Dave A. Cridland Inventure Systems Limited Email: email@example.com URL: http://invsys.co.uk/dave/ 10. Full Copyright Statement Copyright (C) The Internet Society (2005). This document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth therein, the authors retain all their rights. This document and the information contained herein are provided on an "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Acknowledgement Funding for the RFC Editor function is currently provided by the Internet Society. 11. Intellectual Property The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; nor does it represent that it has made any independent effort to identify any such rights. Information on the procedures with respect to rights in RFC documents can be found in BCP 78 and BCP 79. Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr. The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology that may be required to implement this standard. Please address the information to the IETF at ietf- firstname.lastname@example.org. 12. Appendix A. Editorial. <<Note that this section will be deleted before publication>> 12.1 Change Log 00 Initial Revision. 01 Added search correlator. Clarified what should be returned if an extended SEARCH produces no matches. Filled in "IANA considerations" section. Updated references: updated ABNF and added [IMAPABNF]. Changed semantics of the empty list of result options (now equivalent to "(ALL)". 02 Clarified that clients can expect a single ESEARCH result to any extended SEARCH command (for return options described in this document). Added more text on intended purpose of the extension. Added more examples. Updated reference to the ABNF document. 12.2 Open Issues for Discussion Should the syntax allow for return option parameters? It might be convenient to specify "MIN (10)" and then "NEXT (15)" in order to get SEARCH paged results.