【发布时间】:2017-12-18 18:01:05
【问题描述】:
对于特定的全文搜索,我需要修改标准停用词文件并排除一些词。到目前为止我做了什么:
将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 没有使用新的停止列表。我真的不想修改原件,因为我确实想将原件用于其他搜索。
【问题讨论】:
标签: postgresql full-text-indexing