13

I have column col with data type CHARACTER VARYING

I need that index this column as gin index. If trying directly set gin index to column, returned error:

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

If trying:

 create index col_vector 
 on mytable 
 using gin (to_tsvector(col))

I got error: functions in index expression must be marked IMMUTABLE

How to create gin index for CHARACTER VARYING column ?

p.s. I need this for full text search

0

1 Answer 1

21

Try This Code:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.