我的列col
的数据类型为CHARACTER VARYING
我需要将此列的索引作为gin
索引。如果尝试直接将gin index设置为column,则返回错误:
data type character varying has no default operator class for access method "gin"
HINT: You must specify an operator class for the index or define a default operator class for the data type
如果尝试:
create index col_vector
on mytable
using gin (to_tsvector(col))
我收到错误:functions in index expression must be marked IMMUTABLE
如何为gin
列创建CHARACTER VARYING
索引?
P.S。我需要这个用于全文搜索
答案 0 :(得分:13)
试用此代码:
CREATE INDEX "name " ON "tablename" USING gin(to_tsvector('english', "columnname"));