云数据库 GaussDB-Simple词典:操作步骤

时间:2023-11-01 16:22:04

操作步骤

  1. 创建Simple词典。

    1234
    openGauss=# CREATE TEXT SEARCH DICTIONARY public.simple_dict (     TEMPLATE = pg_catalog.simple,     STOPWORDS = english);

    其中,停用词表文件全名为english.stop。关于创建simple词典的语法和更多参数,请参见CREATE TEXT SEARCH DICTIONARY

  2. 使用Simple词典。

     1 2 3 4 5 6 7 8 91011
    openGauss=# SELECT ts_lexize('public.simple_dict','YeS'); ts_lexize ----------- {yes}(1 row)openGauss=# SELECT ts_lexize('public.simple_dict','The'); ts_lexize ----------- {}(1 row)

  3. 设置参数ACCEPT=false,使Simple词典返回NULL,而不是返回非停用词的小写形式。

     1 2 3 4 5 6 7 8 910111213
    openGauss=# ALTER TEXT SEARCH DICTIONARY public.simple_dict ( Accept = false );ALTER TEXT SEARCH DICTIONARYopenGauss=# SELECT ts_lexize('public.simple_dict','YeS'); ts_lexize -----------(1 row)openGauss=# SELECT ts_lexize('public.simple_dict','The'); ts_lexize ----------- {}(1 row)

support.huaweicloud.com/centralized-devg-v2-opengauss/devg_03_0468.html