TSQUERY stores a list of lexemes separated by operators. TSQUERY values are used in .
Syntax
ATSQUERY comprises individual lexemes and operators in the form: 'These' & 'lexemes' & 'are' & 'not' & 'normalized' & 'lexemes.'.
The operators in a TSQUERY are used to . Valid TSQUERY operators are:
&(AND). Given'one' & 'two', bothoneandtwomust be present in the matchingTSVECTOR.|(OR). Given'one' | 'two', eitheroneortwomust be present in the matchingTSVECTOR.!(NOT). Given'one' &! 'two',onemust be present andtwomust not be present in the matchingTSVECTOR.<->(FOLLOWED BY). Given'one' <-> 'two',onemust be followed bytwoin the matchingTSVECTOR.<->is equivalent to<1>. You can specify an integer<nto indicate that lexemes must be separated byn-1other lexemes. Given'one' <4> 'two',onemust be followed by three lexemes and then followed bytwoin the matchingTSVECTOR.
-
One or more weight letters (
A,B,C, orD):'These' & 'lexemes':B & 'are' & 'not' & 'normalized':A & 'lexemes':BIf not specified, a lexeme’s weight defaults toD. It is only necessary to specify weights in aTSQUERYif they are also to be used in a comparison. The lexemes in aTSQUERYandTSVECTORwill only match if they have matching weights. For more information about weights, see the PostgreSQL documentation.
to_tsquery(), plainto_tsquery(), or phraseto_tsquery() to convert a string input to TSQUERY:
- Derivatives of words, which are reduced using a stemming algorithm.
- Stop words. These are words that are considered not useful for indexing and searching, based on the . In the preceding example, “These”, “are”, and “not” are identified as stop words.
- Punctuation and capitalization.

