文本搜索配置(Text Search Configuration),指定了将文档转换成tsvector过程中所必需的组件:
每次to_tsvector或to_tsquery函数调用时,都需要指定一个文本搜索配置来指定具体的处理过程。GUC参数default_text_search_config指定了默认的文本搜索配置,当文本搜索函数中没有显式指定文本搜索配置参数时,将会使用该默认值进行处理。
GaussDB 200中预定义有一些可用的文本搜索配置,用户也可创建自定义的文本搜索配置。此外,为了便于管理文本搜索对象,还提供有多个gsql元命令,可以显示有关文本搜索对象的信息(详细请参见元命令参考)。
CREATE TEXT SEARCH CONFIGURATION ts_conf ( COPY = pg_catalog.english );
CREATE TEXT SEARCH CONFIGURATION
postgres pg
pgsql pg
postgresql pg
执行如下语句创建Synonym词典:
CREATE TEXT SEARCH DICTIONARY pg_dict (
TEMPLATE = synonym,
SYNONYMS = pg_dict,
FILEPATH = 'file:///home/dicts'
);
CREATE TEXT SEARCH DICTIONARY english_ispell (
TEMPLATE = ispell,
DictFile = english,
AffFile = english,
StopWords = english,
FILEPATH = 'file:///home/dicts'
);
ALTER TEXT SEARCH CONFIGURATION ts_conf
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart,
word, hword, hword_part
WITH pg_dict, english_ispell, english_stem;
ALTER TEXT SEARCH CONFIGURATION ts_conf
DROP MAPPING FOR email, url, url_path, sfloat, float;
SELECT * FROM ts_debug('ts_conf', '
PostgreSQL, the highly scalable, SQL compliant, open source object-relational
database management system, is now undergoing beta testing of the next
version of our software.
');
\dF+ ts_conf
Text search configuration "public.ts_conf"
Parser: "pg_catalog.default"
Token | Dictionaries
-----------------+-------------------------------------
asciihword | pg_dict,english_ispell,english_stem
asciiword | pg_dict,english_ispell,english_stem
file | simple
host | simple
hword | pg_dict,english_ispell,english_stem
hword_asciipart | pg_dict,english_ispell,english_stem
hword_numpart | simple
hword_part | pg_dict,english_ispell,english_stem
int | simple
numhword | simple
numword | simple
uint | simple
version | simple
word | pg_dict,english_ispell,english_stem
SET default_text_search_config = 'public.ts_conf';
SET
SHOW default_text_search_config;
default_text_search_config
----------------------------
public.ts_conf
(1 row)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3154349/ ,如需转载,请注明出处,否则将追究法律责任。