我想我们可以使用this old recipe,仅将语言german
替换为语言simple
(即“无语言”)...但是它不起作用。
CREATE TEXT SEARCH DICTIONARY my_synonym (
TEMPLATE = synonym,
SYNONYMS = synonym_sample
-- default /usr/share/postgresql/12/tsearch_data/synonym_sample.syn
);
CREATE TEXT SEARCH CONFIGURATION my_synonym(COPY='simple'); -- need it??
ALTER TEXT SEARCH CONFIGURATION my_synonym
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part
WITH my_synonym -- make sense??
;
SELECT to_tsvector('my_synonym', 'Postgresql')
@@ to_tsquery('my_synonym', 'Postgresql'); -- true
SELECT to_tsvector('my_synonym', 'Postgresql')
@@ to_tsquery('my_synonym', 'pgsql'); -- false. NOTICE:
-- text-search query contains only stop words or doesn't contain lexemes, ignored
SELECT to_tsvector('my_synonym', 'Postgresql pgsql')
@@ to_tsquery('my_synonym', 'pgsql'); -- false. Same NOTICE.
synonym_sample.syn
在当前的Guide's 12.6.3. Synonym Dictionary部分中进行了描述。它将“ pgsql”的缩写转换为“ postgres”一词...因此许多问题
完成同义词替换后,您需要将生成的词素传递给词干。在您链接到的两个示例中都会发生这种情况,但是在您的示例中不会发生这种情况。您可以将“简单”用作虚拟词干提取器,而无需进行任何实际词干提取即可直接传递其输出。
ALTER TEXT SEARCH CONFIGURATION my_synonym
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part
WITH my_synonym, simple;