将 psql 文本列转换为 tsvector

Converting psql text column to tsvector

我正在尝试使用 Rails 迁移将文本列转换为 tsvector:

change_column :people, :title, "tsvector USING title::tsvector"

它遇到了特殊字符,例如:

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error in tsvector: "Project Manager: Software"

出于某种原因,如果我更新该列,比如在末尾添加一个 space,然后重新运行它们迁移,它就会起作用。

知道为什么吗?到目前为止,发生的字段包含::, &, í

to_tsvector() 用于将纯文本转换为 tsvector。

::tsvector 用于断言给定的文本已经是 tsvector 的有效表示,而你的不是。