更新时间:2024-01-31 GMT+08:00
分享

处理tsquery

GaussDB(DWS)提供了函数和操作符用来操作tsquery类型的查询。

  • tsquery && tsquery

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

  • tsquery || tsquery

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

  • !! tsquery

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

  • numnode(query tsquery) returns integer

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

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    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
    (1 row)
    
    SELECT numnode('foo & bar'::tsquery);
     numnode
    ---------
           3
    (1 row)
    
  • querytree(query tsquery) returns text

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

    1
    2
    3
    4
    5
    SELECT querytree(to_tsquery('!defined'));
     querytree 
    -----------
     T
    (1 row)
    
分享:

    相关文档

    相关产品