GBase 8c提供了函数和操作符用来操作tsquery类型的查询。
- tsquery && tsquery
返回两个给定查询tsquery的与结果。
- tsquery || tsquery
返回两个给定查询tsquery的或结果。
- !! tsquery
返回给定查询tsquery的非结果。
- tsquery <-> tsquery
返回给定查询tsquery的<->结果。例如:
gbase=# SELECT to_tsquery('fat') <-> to_tsquery('cat | rat');
?column?
-----------------------------
'fat' <-> ( 'cat' | 'rat' )
(1 row)
- tsquery_phrase(query1 tsquery, query2 tsquery [, distance integer ]) returns tsquery
返回两个给定查询tsquery的距离为distance个词位的匹配。例如:
gbase=# SELECT tsquery_phrase(to_tsquery('fat'), to_tsquery('cat'), 10);
tsquery_phrase
------------------
'fat' <10> 'cat'
(1 row)
- numnode(query tsquery) returns integer
返回tsquery中的节点数目(词素加操作符),这个函数在检查查询是否有效(返回值大于0),或者只包含停用词(返回值等于0)时,是有用的。例如:
gbase=# SELECT numnode('foo & bar'::tsquery);
numnode
---------
3
(1 row)
- querytree(query tsquery) returns text
返回可用于索引搜索的tsquery部分,该函数对于检测非索引查询是有用的(例如只包含停用词或否定项)。例如:
gbase=# SELECT querytree(to_tsquery('!defined'));
querytree
-----------
T
(1 row)