11
CREATE INDEX message_fulltext_idx ON feedback USING gin(to_tsvector(message));
ERROR: functions in index predicate must be marked IMMUTABLE
如何避免这种情况?Postgres的全文索引
CREATE INDEX message_fulltext_idx ON feedback USING gin(to_tsvector(message));
ERROR: functions in index predicate must be marked IMMUTABLE
如何避免这种情况?Postgres的全文索引
您需要包含可选的配置参数。没有它,这个函数并不是不可变的。例如,如果您想标准英文文本解析:
CREATE INDEX message_fulltext_idx ON feedback
USING gin(to_tsvector('english', message));
这是正确的答案。第一种形式的'to_tsvector'将使用来自设置'default_text_search_config'的config参数的默认值。由于这是一个可改变的设置,该功能并不是不变的。如果它发生变化,基于非模仿函数的现有索引将被无声地破坏。所以这是禁止的。请参阅http://www.postgresql.org/docs/current/static/textsearch-tables.html#TEXTSEARCH-TABLES-INDEX。 – Edmund 2012-04-05 12:46:02