This topic describes how to run full-text searches in Chinese to query data from an ApsaraDB RDS for PostgreSQL instance by using the pg_jieba plug-in.

Prerequisites

Procedure

  • Create the pg_jieba plug-in.
    CREATE EXTENSION pg_jieba;
    Note Only privileged accounts are authorized to run the preceding command.
  • Delete the pg_jieba plug-in.
    DROP EXTENSION pg_jieba;
    Note Only privileged accounts are authorized to run the preceding command.
  • Example 1:
    select * from to_tsvector('jiebacfg', '小明硕士毕业于中国科学院计算所,后在日本京都大学深造');
                                                     to_tsvector
    --------------------------------------------------------------------------------------------------------------
     '中国科学院':5 '于':4 '后':8 '在':9 '小明':1 '日本京都大学':10 '毕业':3 '深造':11 '硕士':2 '计算所':6 ',':7
    (1 row)
  • Example 2:
    select * from to_tsvector('jiebacfg', '李小福是创新办主任也是云计算方面的专家');
                                            to_tsvector
    -------------------------------------------------------------------------------------------
     '专家':11 '主任':5 '也':6 '云计算':8 '创新':3 '办':4 '方面':9 '是':2,7 '李小福':1 '的':10
    (1 row)