plainto_tsquery()

将文本转换为 tsquery 的函数

plainto_tsquery() 是一个用于将纯文本转换为 tsquery 数据类型的系统函数。

plainto_tsquery()PostgreSQL 8.3 中添加。

用法

plainto_tsquery ( [ config regconfig, ] query text ) → tsquery

单词根据指定的或默认的配置进行规范化。字符串中的任何标点符号都将被忽略,并且不会被用作查询运算符。

请注意,只有包含生成的、规范化后的 tsquery 中所有单词的文档才会匹配。有关更灵活的匹配,请参阅 websearch_to_tsquery()。要匹配特定短语,请参阅 phraseto_tsquery()

变更历史

示例

plainto_tsquery() 的基本用法示例

postgres=# SELECT plainto_tsquery('The Quick Brown Fox');
      plainto_tsquery      
---------------------------
 'quick' & 'brown' & 'fox'
(1 row)

前面函数调用产生的 tsquery 将匹配包含所有这三个单词的文档

postgres=# SELECT to_tsvector('a quick brown fox') @@ plainto_tsquery('The Quick Brown Fox');
 ?column? 
----------
 t
(1 row)

postgres=# SELECT to_tsvector('a brown fox is quick') @@ plainto_tsquery('The Quick Brown Fox');
 ?column? 
----------
 t
(1 row)

但不匹配只包含这些单词子集的文档

postgres=# SELECT to_tsvector('a slow brown fox') @@ plainto_tsquery('The Quick Brown Fox');
 ?column? 
----------
 f
(1 row)

分类

全文搜索, 系统函数

另请参阅

to_tsquery()phraseto_tsquery()websearch_to_tsquery()

反馈

提交关于“plainto_tsquery()”的任何评论、建议或更正,请在此处 提交