For a particular full text search I need to modify the standard stopword file and exclude some words. What I did so far:
Copied german.stop
to german_modified.stop
and then
removed the words from german_modified.stop
. Then:
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));
But when I do
SELECT body, autor
FROM comments
WHERE to_tsvector('german_nostop', body) @@ to_tsquery('wie');
I get:
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'
is the word that I removed from the modified stop words list. For some reason PostgreSQL did not use the new stoplist. I do not really want to modify the original since I do want to use the origal for other searches.