23
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?

0

1 Answer 1

28

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)); 
Sign up to request clarification or add additional context in comments.

1 Comment

This is the correct answer. The first form of 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/….

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.