对于特定的全文搜索,我需要修改标准的stopword文件并排除一些单词。到目前为止,我所做的:
将german.stop复制到german_modified.stop,然后从german_modified.stop中删除单词。然后:
CREATE TEXT SEARCH DICTIONARY public.german_nostop (
TEMPLATE = pg_catalog.simple,
STOPWORDS = german_modified
);
CREATE TEXT SEARCH CONFIGURATION public.german_nostop (
COPY = pg_catalog.german
);
ALTER TEXT SEARCH CONFIGURATION public.german_nostop
ALTER MAPPING
FOR asciiword, asciihword, hword_asciipart, hword, hword_part, word
WITH german_nostop;
CREATE INDEX body_idx ON comments
USING gin (to_tsvector('german_nostop', body));但当我这么做的时候
SELECT body, autor
FROM comments
WHERE to_tsvector('german_nostop', body) @@ to_tsquery('wie');我得到了:
NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored
NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored
NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored
body | autor
------+-------
(0 rows)'wie'是我从修改的停用词列表中删除的词。出于某种原因,PostgreSQL没有使用新的非索引字表。我真的不想修改原始的,因为我确实想使用原始的其他搜索。
发布于 2017-12-19 15:44:29
您忘记将文本搜索配置添加到to_tsquery呼叫。
你应该这样写:
to_tsquery('german_nostop', 'wie')to_tsquery还删除了停用词,因为它默认使用german配置,所以删除了'wie'。
如果希望将新的文本搜索配置设置为默认设置,可以将default_text_search_config设置为german_nostop。
https://stackoverflow.com/questions/47873990
复制相似问题