CREATE INDEX message_fulltext_idx ON feedback USING gin(to_tsvector(message));
ERROR: functions in index predicate must be marked IMMUTABLE
How to avoid this?
You need to include the optional config parameter. Without it, the function is not immutable. For example, if you want the standard English text parsing:
CREATE INDEX message_fulltext_idx ON feedback
USING gin(to_tsvector('english', message));
to_tsvector will use a default for the config parameter that comes from the setting default_text_search_config. Since that is a changable setting, the function is not immutable. If it were to change, an existing index based on the non-mimmutable function would be silently corrupted. So it's forbidden. See postgresql.org/docs/current/static/….