Search argument syntax

A search argument is the condition that is specified as part of a search for terms in text documents. It consists of search parameters and one or more search terms. The SQL scalar text search functions that use search arguments are CONTAINS and SCORE.

For any language-specific processing during a search, you can specify a value for the QUERYLANGUAGE parameter as a search argument option. The value can be any of the supported language codes. If the QUERYLANGUAGE parameter is not specified, the default value is the language value of the text search index that is used when this function is invoked. If the language value of the text search index is AUTO, the default value for QUERYLANGUAGE is en_US.

Simple search

To do a simple keyword search, you can enter one or more query terms (keywords). The search engine returns documents that contain all of those keywords, or variations of the keywords.

A keyword search is not case-sensitive. Therefore, a query for the term king will return matches for the terms King and Kings, and vice versa.

For example, if you enter king, the search engine returns all documents that contain the term king, or certain variations of the term such as kings. If you enter the query king lear, the search engine returns documents that contain the terms king and lear.

To see more precise results, use more specific keywords. For example, use French roast coffee rather than coffee, or use Kauai hiking tours rather than Hawaiian vacations.

If a simple keyword search returns too many documents that are not what you are looking for, you can use operators to refine your search.

Exclusion of terms in a search

Use the minus sign (-) to exclude terms. For example, if you want to find documents with the term lear, and you do not want to see documents with king, enter the query lear -king.

The minus sign (-) also applies to a term and its variants. For example, the query -king will exclude documents that contain the word kings.

Phrase search

If you want to ensure that terms appear in the same order as you typed them in and that term variants are not a match, you can use double quotation marks. For example, if you want to find documents with the term king lear exactly, and you do not want matches on related phrases such as king and queen lear, enter "king lear". A phrase search is not case-sensitive.

Wildcard character in a search

The wildcard character (*) helps you find documents when you do not know the full spelling of a term. By using the wildcard character, you also find variations of the term. For example, the query czech* returns documents with the terms czech, czechoslovakia, czechoslovakian, and other possible results.

You can also use the wildcard character in a phrase search. For example, the query "John * Kennedy" returns documents with the terms John Fitzgerald Kennedy and John F Kennedy but not John Kennedy. The query Mi*l Gorbachev will return Mikhail Gorbachev.

You can use a wildcard character at the beginning of a query (for example, *king), but doing so might cause the search engine to take longer to return results.

Note: Wildcard card characters are ignored when processing Chinese, Japanese, and Korean documents.

Searches for at least one of the terms

The logical operator OR specifies that at least one of the terms in a query must appear in the returned document. For example, the query (othello OR otello) returns documents that contain the term othello or otello.

You can also use the logical operators AND, OR, and NOT in combinations by using parentheses. For example, the query cougar OR (jaguar AND NOT car) returns documents with the term cougar, or documents that contain the term jaguar but not the term car.

You must enter the logical operators AND, OR, and NOT in all uppercase. Use parentheses for grouping.

Fuzzy searches

A fuzzy search query searches for character sequences that are not only the same but similar to the query term. Use the tilde symbol (~) at the end of a term to do a fuzzy search. For example, the following query finds documents that include the terms analytics, analyze, analysis, and so on.

analytics~

You can add an optional parameter to specify the required similarity. Specify a value greater than 0 and less than 1. The value must be preceded by a 0 and decimal point (for example, 0.8). A value closer to 1 matches terms with a higher similarity. If the parameter is not specified, the default is 0.5.

analytics~0.8
Restriction: Special characters are not supported in fuzzy search queries. Avoid using double quotation marks (") in fuzzy search queries. If you enclose a search argument in quotation marks, the query is processed like an exact match search. For example, the search argument CONTAINS (index,'"token"~0.8') is processed as CONTAINS (index,'token'). Also, using the following types of non-alphabetic and nonnumeric characters in a fuzzy search term might cause unexpected results: @ + − & ∥ ! ( ) { } [ ] ^ " ~ * ? : \.

Proximity searches

A proximity search finds documents that contain terms within a specified number of words of each other. Use the tilde symbol (~) to do a proximity search. For example, the following query finds documents that contain "IBM®" and "WebSphere®" within seven words of each other.

"IBM WebSphere"~7

Proximity search is supported for individual terms but not for phrases. Also, a word after a sentence break is not considered adjacent to words in the previous sentence.

Restriction: Special characters are not supported in proximity search queries.