How to refresh stop-words list without restart postgres server?

Viewed 244

I have custom search configuration with stop-words. What I need to do to make the postgres server see the changes in the list of stop-words?

upd 1

I created file russian_extended.stop in catalog pg10\share\postgresql\tsearch_data.

Then I executed commands

CREATE TEXT SEARCH DICTIONARY public.russian_extended (
        TEMPLATE = pg_catalog.simple,
        STOPWORDS = russian_extended
    );

and then

CREATE TEXT SEARCH CONFIGURATION public.russian_extended (
        COPY = pg_catalog.russian
    );

and in the end

ALTER TEXT SEARCH CONFIGURATION public.russian_extended
        ALTER MAPPING
            FOR asciiword, asciihword, hword_asciipart, hword, hword_part, word
            WITH russian_extended;

upd 2

After that I add a new word to the list and I don't understand how to apply this changes on the fly without restart my postgres server ...

2 Answers

I missed the solution in the official documentation, my fail was that I put into the list result of function to_tsvector

ALTER TEXT SEARCH DICTIONARY public.russian_extended (StopWords=russian_extended);

From my reading of the source, a text search dictionary is initialized whenever the dictionary is first used, or after a cache invalidation (function lookup_ts_dictionary_cache).

So just starting a new database session should make changes in the stopword file active.

I did not verify if that is the case, can you test?

If you have any full text search indexes using a configuration with a dictionary where you changed the stopword file, you'll have to rebuild these indexes.

Related