9.13. 文字檢索函式及運算子
Table 9.40,Table 9.41andTable 9.42summarize the functions and operators that are provided for full text searching. SeeChapter 12for a detailed explanation ofPostgreSQL's text search facility.
Table 9.40. Text Search Operators
Operator | Return Type | Description | Example | Result | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
| |||||||
|
| deprecated synonym for |
|
| |||||||
` | ` |
| concatenate | `'a:1 b:2'::tsvector | 'c:1 d:2 b:3'::tsvector` |
| |||||
|
| AND | `'fat | rat'::tsquery && 'cat'::tsquery` | `( 'fat' | 'rat' ) & 'cat'` | |||||
` | ` |
| OR | `'fat | rat'::tsquery | 'cat'::tsquery` | `( 'fat' | 'rat' ) | 'cat'` | ||
|
| negate a |
|
| |||||||
|
|
|
|
| |||||||
|
|
|
|
| |||||||
|
|
|
|
|
Note
Thetsquery
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 typestsvector
andtsquery
. 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 |
|
| ||
|
| get indexable part of a |
|
| ||
|
| assign |
|
| ||
|
| assign |
|
| ||
|
| remove positions and weights from |
|
| ||
|
| normalize words and convert to |
|
| ||
|
| reduce document text to |
|
| ||
|
| reduce each string value in the document to a |
|
| ||
|
| remove given |
|
| ||
|
| remove any occurrence of lexemes in |
|
| ||
|
| select only elements with given |
|
| ||
|
| display a query match |
|
| ||
|
| display a query match |
|
| ||
|
| rank document for query |
|
| ||
|
| rank document for query using cover density |
|
| ||
|
| replace | `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 |
|
| ||
|
| make query that searches for |
|
| ||
|
| convert |
|
| ||
|
| trigger function for automatic |
| |||
|
| trigger function for automatic |
| |||
|
| expand a tsvector to a set of rows |
|
|
Note
All the text search functions that accept an optionalregconfig
argument will use the configuration specified bydefault_text_search_configwhen that argument is omitted.
The functions inTable 9.42are 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 |
|
|