How to write queries

The boolean full-text search capability supports the following operators:

+

A leading plus sign indicates that this word must be present in each search result that is returned.

-

A leading minus sign indicates that this word must not be present in any of the search results that are returned.

Note: The - operator acts only to exclude search results that are otherwise matched by other search terms. Thus, a boolean-mode search that contains only terms preceded by - returns an empty result. It does not return "all items except those containing any of the excluded terms."

(no operator)

By default (when neither + nor - is specified) the word is optional, but the search results that contain it are rated higher.

< >

These two operators are used to change a word's contribution to the relevance value that is assigned to a search result. The > operator increases the contribution and the < operator decreases it. See the example following this list.

( )

Parentheses group words into subexpressions. Parenthesized groups can be nested.

~

A leading tilde acts as a negation operator, causing the word's contribution to the search result's relevance to be negative. This is useful for marking "noise" words. A result containing such a word is rated lower than others, but is not excluded altogether, as it would be with the - operator.

*

The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the * operator.

If a stopword or too-short word is specified with the truncation operator, it will not be stripped from a boolean query. For example, a search for '+word +stopword*' will likely return fewer search results than a search for '+word +stopword' because the former query remains as is and requires stopword* to be present in a document. The latter query is transformed to +word.

"

A phrase that is enclosed within double quote characters ("search phrase") matches only search results that contain the phrase literally, as it was typed. Nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example, "test phrase" matches "test, phrase".

If the phrase contains no words that are in the index, the result is empty. For example, if all words are either stopwords or shorter than 3 letters, the result is empty.

The following examples demonstrate some search strings that use boolean full-text operators:

apple banana

Find items that contain at least one of the two words.

+apple +juice

Find items that contain both words.

+apple macintosh

Find items that contain the word "apple", but rank rows higher if they also contain "macintosh".

+apple -macintosh

Find items that contain the word "apple" but not "macintosh".

+apple ~macintosh

Find items that contain the word "apple", but if the item also contains the word "macintosh", rate it lower than if item does not. This is "softer" than a search for '+apple -macintosh', for which the presence of "macintosh" causes the item not to be returned at all.

+apple +(>turnover <strudel)

Find items that contain the words "apple" and "turnover", or "apple" and "strudel" (in any order), but rank "apple turnover" higher than "apple strudel".

apple*

Find items that contain words such as "apple", "apples", "applesauce", or "applet".

"some words"

Find items that contain the exact phrase "some words" (for example, items that contain "some words of wisdom" but not "some noise words"). Note that the " characters that enclose the phrase are operator characters that delimit the phrase. They are not the quotes that enclose the search string itself.