rfc-6203

IMAP4 Extension for Fuzzy Search

T. Sirainen
date2011-03 streamIETF areaapp wgmorg statusPROPOSED STANDARD pages7 canonicalhttps://www.rfc-editor.org/rfc/rfc6203 doi10.17487/RFC6203
This document describes an IMAP protocol extension enabling a server to perform searches with inexact matching and assigning relevancy scores for matched messages. [STANDARDS-TRACK]

Extracted elements (22)

design-rationale §5

Fuzzy matching is extended to non-string keys (dates, sizes, flags) so that a single FUZZY qualifier covers an entire search expression. For example, date ranges may return messages outside the range with lower scores to model queries like "about a week ago".

email

design-rationale §3

Fuzzy search results are explicitly non-deterministic: the same query may return different results for the same user at different times, for different users simultaneously, or due to load-balancing decisions. Clients must warn users accordingly.

email

design-rationale §4

Relevancy score is defined as relevance to the search rather than precision of match. A fuzzy subject match may score higher than an exact body match mid-sentence, enabling servers to rank by user intent rather than literal string similarity.

email

design-rationale §3

The FUZZY key is permitted to ignore the active comparator (RFC 5255) because relevance-ranked full-text search algorithms require implementation freedom; forcing a specific comparator would prevent servers from using their best matching strategies.

email

interoperability-note §6

When the server advertises CONTEXT=SORT or CONTEXT=SEARCH (RFC 5267), clients can use the PARTIAL return option to limit the number of returned messages, e.g., retrieving only the 10 most relevant results.

email

interoperability-note §4

When the server also advertises the ESEARCH capability (RFC 4731), the RELEVANCY return option becomes available on SEARCH to retrieve per-message relevancy scores alongside the result set.

email

interoperability-note §6

When the server also advertises the SORT capability (RFC 5256), results can be ordered by RELEVANCY sort criteria. When ESORT (CONTEXT, RFC 5267) is advertised, SORT RETURN (RELEVANCY ALL) can retrieve both sorted UIDs and their scores.

email

normative-requirement §5 SHOULD

All search keys SHOULD be matched fuzzily, although the server may decide that fuzzy matching is meaningless for a particular key and fall back to exact matching.

email

normative-requirement §8 MAY

Servers MAY limit the resources that a single search or a single user may use, to guard against denial-of-service attacks enabled by the fuzzy search extension.

email, security

normative-requirement §4 SHOULD

Servers SHOULD assign a search relevancy score for each matched message when the FUZZY search key is given. Relevancy scores are given in the range 1-100, where 100 is the highest relevancy.

email

normative-requirement §4 MUST NOT

The RELEVANCY return option MUST NOT be used unless a FUZZY search key is also given in the SEARCH command.

email

normative-requirement §4 SHOULD

The relevancy scores SHOULD use the full 1-100 range so that clients can display them meaningfully to users, e.g., as a percentage value.

email

normative-requirement §6 MUST NOT

The RELEVANCY sort criteria MUST NOT be used unless a FUZZY search key is also given in the SORT command.

email

protocol-element §3

The FUZZY search key takes another search key as its argument and allows the server to perform matching in an implementation-defined manner, including ignoring the active comparator. It enables inexact matching for string searches and other key types.

email

protocol-element §4

The RELEVANCY return option for SEARCH (when ESEARCH is advertised) returns a score-list alongside the matched message set, e.g., `* ESEARCH (TAG "B1") ALL 1,5,10 RELEVANCY (4 99 42)`.

email

protocol-element §6

The RELEVANCY sort criterion for SORT (when SORT capability is advertised) orders results so the message with the highest relevancy score is returned first.

email

registry §9

This document registers the SEARCH=FUZZY capability in the IANA "Internet Message Access Protocol (IMAP) 4 Capabilities Registry".

email, registry

security-consideration §8

Fuzzy search engines can have non-obvious resource usage patterns. Implementors should test with large messages containing very long words and/or unique random strings, and with very long search keys, to prevent excessive memory or CPU consumption.

email, security

security-consideration §8

Invalid input such as illegal UTF-8 sequences in message data fed to a UTF-8-expecting search engine may cause failures. Servers should validate input and replace illegal sequences, e.g., with the Unicode replacement character U+FFFD.

email, security

security-consideration §8

Relevancy rankings may be susceptible to poisoning by attackers using certain keywords or hidden markup (e.g., HTML) to boost message scores. Clients should mitigate this by allowing users to see all search results rather than hiding those below a score threshold.

email, security

wire-format §7

A relevancy score is encoded as `score = 1*3DIGIT` with the constraint 1 <= n <= 100. A score-list is encoded as `"(" [score *(SP score)] ")"`, a space-separated list of scores in parentheses.

email

wire-format §7

The SEARCH=FUZZY capability string is added to the IMAP capability response. The `search-key` production is extended with `"FUZZY" SP search-key`, and `sort-key` is extended with `"RELEVANCY"`.

email