#openGauss #入门 #安装 #数据库 #开源
知识来源:docs-opengauss.osinfra.cn/zh/
3. 使用TZ词典。
-
测试TZ词典。
ts_lexize函数对于测试TZ词典作用不大,因为该函数是按照单个token处理输入。可以使用plainto_tsquery、to_tsvector、to_tsquery函数测试TZ词典,这些函数能够将输入分解成多个token(to_tsquery函数需要将输入加上引号)。
openGauss=# SELECT plainto_tsquery('russian','supernova star'); plainto_tsquery ----------------- 'sn' (1 row) openGauss=# SELECT to_tsvector('russian','supernova star'); to_tsvector ------------- 'sn':1 (1 row) openGauss=# SELECT to_tsquery('russian','''supernova star'''); to_tsquery ------------ 'sn' (1 row)其中,supernova star匹配了词典thesaurus_astro定义中的supernovae stars,这是因为在thesaurus_astro词典定义中指定了Snowball类型的子词典english_stem,该词典移除了e和s。
-
如果同时需要索引原始短语,只要将其同时放置在词典定义文件中对应定义的右侧即可,如下:
supernovae stars : sn supernovae stars openGauss=# ALTER TEXT SEARCH DICTIONARY thesaurus_astro ( DictFile = thesaurus_astro, FILEPATH = 'file:///home/dicts/'); openGauss=# SELECT plainto_tsquery('russian','supernova star'); plainto_tsquery ----------------------------- 'sn' & 'supernova' & 'star' (1 row)
#openGauss #入门 #安装 #数据库 #开源