postgresql 全文搜索的索引列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16518176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Indexing column for full text search
提问by Oto Shavadze
I have column col
with data type CHARACTER VARYING
我有col
数据类型的列CHARACTER VARYING
I need that index this column as gin
index. If trying directly set gin index to column, returned error:
我需要将该列作为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
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
我有错误: functions in index expression must be marked IMMUTABLE
How to create gin
index for CHARACTER VARYING
column ?
如何gin
为CHARACTER VARYING
列创建索引?
p.s. I need this for full text search
ps 我需要这个进行全文搜索
回答by Sathish
Try This Code:
试试这个代码:
CREATE INDEX "name " ON "tablename" USING gin(to_tsvector('english', "columnname"));