更新时间:2025-05-29 GMT+08:00
文本检索操作符
@@
描述:tsvector类型的词汇与tsquery类型的词汇是否匹配。
示例:
1 2 3 4 5 |
gaussdb=# SELECT to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat') AS RESULT; result -------- t (1 row) |
@@@
描述:@@的同义词。
示例:
1 2 3 4 5 |
gaussdb=# SELECT to_tsvector('fat cats ate rats') @@@ to_tsquery('cat & rat') AS RESULT; result -------- t (1 row) |
||
- 描述:将两个tsquery类型的词汇进行“或”操作。
1 2 3 4 5
gaussdb=# SELECT 'fat | rat'::tsquery || 'cat'::tsquery AS RESULT; result --------------------------- ( 'fat' | 'rat' ) | 'cat' (1 row)
&&
描述:将两个tsquery类型的词汇进行“与”操作。
示例:
1 2 3 4 5 |
gaussdb=# SELECT 'fat | rat'::tsquery && 'cat'::tsquery AS RESULT; result --------------------------- ( 'fat' | 'rat' ) & 'cat' (1 row) |
!!
描述:tsquery类型词汇的非关系。
示例:
1 2 3 4 5 |
gaussdb=# SELECT !! 'cat'::tsquery AS RESULT; result -------- !'cat' (1 row) |
@>
描述:一个tsquery类型的词汇是否包含另一个tsquery类型的词汇。
示例:
1 2 3 4 5 |
gaussdb=# SELECT 'cat'::tsquery @> 'cat & rat'::tsquery AS RESULT; result -------- f (1 row) |
<@
描述:一个tsquery类型的词汇是否被包含另一个tsquery类型的词汇。
示例:
1 2 3 4 5 |
gaussdb=# SELECT 'cat'::tsquery <@ 'cat & rat'::tsquery AS RESULT; result -------- t (1 row) |
除了上述的操作符,还为tsvector类型和tsquery类型的数据定义了普通的B-tree比较操作符(=,<等)。
父主题: 文本检索函数和操作符