2013-05-13 268 views
5

索引列我有列col數據類型CHARACTER VARYING全文搜索

我需要指數在列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列?

p.s.我需要這個全文搜索

+0

這本手冊中的全文搜索討論。 – 2013-05-13 23:37:59

回答

8

試試這個代碼:

CREATE INDEX "name " ON "tablename" USING gin(to_tsvector('english', "columnname")); 
+0

下面是解釋:http://www.postgresql.org/docs/9.3/static/textsearch-tables.html – 2014-08-26 03:38:29