PostgreSQL
9.13. Text Search Functions and Operators
Table 9.40, Table 9.41 and Table 9.42 summarize the functions and operators that are provided for full text searching. See Chapter 12 for a detailed explanation of PostgreSQL’s text search facility.
Table 9.40. Text Search Operators
Operator | Return Type | Description | Example | Result |
---|---|---|---|---|
|
|
|
|
|
|
|
deprecated synonym for |
|
|
`+ |
+` |
|
concatenate `tsvector`s |
|
`+'a:1 b:2'::tsvector |
'c:1 d:2 b:3'::tsvector+` |
|
|
|
|
AND `tsquery`s together |
`+'fat |
rat'::tsquery && 'cat'::tsquery+` |
`+( 'fat' |
'rat' ) & 'cat'+` |
`+ |
+` |
|
|
OR `tsquery`s together |
`+'fat |
rat'::tsquery |
'cat'::tsquery+` |
|
`+( 'fat' |
'rat' ) |
'cat'+` |
|
|
negate a |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
Note
The tsquery
containment operators consider only the lexemes listed in the two queries, ignoring the combining operators.
In addition to the operators shown in the table, the ordinary B-tree comparison operators (=
, <
, etc) are defined for types tsvector
and tsquery
. These are not very useful for text searching but allow, for example, unique indexes to be built on columns of these types.
Table 9.41. Text Search Functions
Function | Return Type | Description | Example | Result |
---|---|---|---|---|
|
|
convert array of lexemes to |
|
|
|
|
get default text search configuration |
|
|
|
|
number of lexemes in |
|
|
|
|
number of lexemes plus operators in |
`+numnode('(fat & rat) |
cat'::tsquery)+` |
|
|
|
produce |
|
|
|
|
produce |
|
|
|
|
produce |
|
`+'fat' <→ 'rat' |
'rat'+` |
|
|
get indexable part of a |
|
|
|
|
assign `weight |
|
|
|
|
assign `weight |
|
|
|
|
remove positions and weights from |
|
|
|
|
normalize words and convert to |
|
|
|
|
reduce document text to |
|
|
|
|
reduce each string value in the document to a |
|
|
|
|
reduce each value in the document, specified by `filter |
|
|
|
|
remove given `lexeme |
|
|
|
|
remove any occurrence of lexemes in `lexemes |
|
|
|
|
select only elements with given `weights |
|
|
|
|
display a query match |
|
|
|
|
display a query match |
|
|
|
|
rank document for query |
|
|
|
|
rank document for query using cover density |
|
|
|
|
replace `target |
`+ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'foo |
bar'::tsquery)+` |
`+'b' & ( 'foo' |
'bar' )+` |
|
|
replace using targets and substitutes from a |
|
`+'b' & ( 'foo' |
'bar' )+` |
|
|
make query that searches for `query1 |
|
|
|
|
make query that searches for `query1 |
|
|
|
|
convert |
|
|
|
|
trigger function for automatic |
|
|
|
|
trigger function for automatic |
|
|
|
|
expand a |
|
|
+
Note
All the text search functions that accept an optional regconfig
argument will use the configuration specified by default_text_search_config when that argument is omitted.
The functions in Table 9.42 are listed separately because they are not usually used in everyday text searching operations. They are helpful for development and debugging of new text search configurations.
Table 9.42. Text Search Debugging Functions
Function | Return Type | Description | Example | Result |
---|---|---|---|---|
|
|
test a configuration |
|
|
|
|
test a dictionary |
|
|
|
|
test a parser |
|
|
|
|
test a parser |
|
|
|
|
get token types defined by parser |
|
|
|
|
get token types defined by parser |
|
|
|
|
get statistics of a |
|
|
+
Prev | Up | Next |
---|---|---|
9.12. Network Address Functions and Operators |
9.14. XML Functions |
Copyright © 1996-2023 The PostgreSQL Global Development Group