处理查询

openGauss提供了函数和操作符用来操作tsquery类型的查询。

  • tsquery && tsquery

    返回两个给定查询tsquery的与结果。

  • tsquery || tsquery

    返回两个给定查询tsquery的或结果。

  • !! tsquery

    返回给定查询tsquery的非结果。

  • numnode(query tsquery) returns integer

    返回tsquery中的节点数目(词素加操作符),这个函数在检查查询是否有效(返回值大于0),或者只包含停用词(返回值等于0)时,是有用的。例如:

    openGauss=# SELECT numnode(plainto_tsquery('the any'));
    NOTICE:  text-search query contains only stop words or doesn't contain lexemes, ignored
    CONTEXT:  referenced column: numnode
     numnode 
    ---------
           0
    
    openGauss=# SELECT numnode('foo & bar'::tsquery);
     numnode
    ---------
           3
    
  • querytree(query tsquery) returns text

    返回可用于索引搜索的tsquery部分,该函数对于检测非索引查询是有用的(例如只包含停用词或否定项)。例如:

    openGauss=# SELECT querytree(to_tsquery('!defined'));
     querytree 
    -----------
     T
    (1 row)
    
意见反馈
编组 3备份
openGauss 2024-03-19 00:47:31
取消