I need to remove not words, but phrases, e.g. "delete this".
AFAIK only thesaurus dictionary supports phrases, so I tried create a dictionary with an empty replacement:
delete this :
But PG responds with an error when attempting to create this dictionary. Seems like the replacement can't be empty.
My next attempt was to use thesaurus to map phrases to a special token:
delete this : deletethis
And then have a stop word dictionary remove this special token. I'd map the dictionaries in a sequence:
ALTER TEXT SEARCH CONFIGURATION public.my_cfg
ALTER MAPPING FOR asciiword
WITH public.my_thesaurus, public.my_simple_stop;
But this just results in:
> select to_tsvector('my_cfg', 'delete this');
deletethis
Seems like once thesaurus "claimed" a token sequence, and emitted another, this ends processing without consulting the next dictionary. PG's documentation does mention that only "filtering dictionaries" pass on their output further - I guess thesaurus isn't one.
Are there any other options to implement stop phrases? Besides the obvious "preprocess text by calling your function before passing over to tsquery/tsvector". I'm interested in a text search configuration integrated solution.