13

我有col数据类型的列CHARACTER VARYING

我需要该列作为gin索引。如果尝试直接将 gin 索引设置为列,则返回错误:

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

ps 我需要这个来进行全文搜索

4

1 回答 1

19

试试这个代码:

CREATE INDEX "name " ON "tablename" USING gin(to_tsvector('english', "columnname"));
于 2013-05-13T09:25:52.553 回答