Text search argument syntax

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

For information on CONTAINS and SCORE, see CONTAINS and SCORE.

For more information on text search, see OmniFind Text Search Server for DB2® for i

Syntax

Read syntax diagramSkip visual syntax diagramqualified-clause operatorqualified-clause
operator
Read syntax diagramSkip visual syntax diagramANDOR
qualified-clause
Read syntax diagramSkip visual syntax diagrammodifierclause boost
modifier
Read syntax diagramSkip visual syntax diagram +  - NOT
clause
Read syntax diagramSkip visual syntax diagramunqualified-termopaque-term
boost
Read syntax diagramSkip visual syntax diagram ^ number

Description

A search argument is a term or sequence of terms, separated by white space, specified when searching in text documents. It consists of one or more search terms and various optional search parameters.

To perform a simple search, you can enter one or more terms. The search engine returns documents that contain all of those terms or variations of those terms. For example, if you perform a search on the term king, documents containing king are returned. By default, the search engine also returns variants of the search term. Thus, documents containing kings are also returned. Similarly, when you search on two terms, the search engine returns documents containing both terms. If you want the terms to be searched as an exact phrase, simply add quotation marks.

The more specific the search term you use, the more precise the results. However, you may also want to refine your searches by using one or more of the following options:

operator
Specifies whether the search for either or both qualified clauses on either side of the operator must be satisfied.
AND
The search for both qualified clauses on either side of the operator must be satisfied.
OR
The search for at least one of the qualified clauses on either side of the operator must be satisfied.

Similar to search conditions in SQL, parentheses can be used to determine which qualified clauses and operators are evaluated first. If parentheses are not specified, AND is applied before OR.

modifier
Each clause can have an occurrence modifier. If a modifier is not specified for a clause, the default is plus (+).
+
The clause is required in the document.
- or NOT
The clause must not be specified in the document.
?
The clause is optional in the document.
clause
Specifies a search string. In the search string, the question mark and asterisk have special meanings. Use a question mark (?) to represent any single character, and an asterisk (*) to represent a string of zero or more characters. If the search string contains multiple words that should be treated as a phrase, include quotation marks (") around the search string. Blanks within a clause are ignored.
unqualified-term
An unqualified term is simply a term or a phrase. A term can be a word, such as king; an exact word, such as "king"; or a word that includes a question mark (?) to represent any single character, and an asterisk (*) to represent a string of zero or more characters, such as king* or king?. Similarly, a phrase can be a group of words, such as cabbages and kings; an exact phrase, such as "The King and I"; or a phrase that includes a wildcard, such as "all the king's ho*ses" or "all the king's ?".

If a character in clause is one of the characters that has a special meaning in the syntax of the search argument, an escape character (\) can be used to indicate that the subsequent character should be treated as a regular character in the clause.

opaque-term
An opaque query term is so called because it is not parsed by the linguistic query parser; opaque terms are identified by their syntax. The opaque term used for text search queries that include XML markup is @xmlxp,, for example: @xmlxp:'/TagA/TagB[. contains("king")]'
boost
boost can be specified for each clause. boost provides a higher or lower importance to occurrences of the clause.
number
Specifies a decimal or integer constant that is greater than 0. If boost is not specified for a clause, the default boost value is 1.

Notes

Case sensitivity: Searches are not case sensitive, so a search in Spanish for the exact term "DOS" could return documents containing DOS or dos.