Gru*_*led 6 full-text-search ruby-on-rails-3 pg-search
我使用multisearch在我的Rails 3.2.3应用程序上运行了pg_search.然后我在这篇文章中实现了nertzy(pg_search的作者)提供的初始化程序..现在,当我运行搜索时,我收到以下错误:
PG::Error: ERROR: operator does not exist: text % unknown
LINE 1: ... ((coalesce("pg_search_documents"."content", '')) % 'searchterm...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)
我的视图使用以下代码呈现:
<%= @pg_search_documents.each do |pg_search_document| %>
<%= pg_search_document.searchable.title %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
ste*_*wne 11
我之前也遇到过这个问题.只是为了澄清可能遇到麻烦的其他人...这里是如何安装扩展程序:
通过运行创建新的迁移
bundle exec rails g migration add_trigram_extension
Run Code Online (Sandbox Code Playgroud)在迁移中,粘贴以下代码:
def up
execute "create extension pg_trgm"
end
def down
execute "drop extension pg_trgm"
end
Run Code Online (Sandbox Code Playgroud)使用运行迁移 bundle exec rake db:migrate
这对我来说很有帮助.您可以与pg_search一起使用的某些扩展或配置需要更新版本的Postgres.为了在heroku上使用某些扩展,您可能需要使用dev数据库.
更新:我的理解是heroku已经发布滚动升级,现在每个人都默认运行更新版本的pg.以上应该适用于heroku而无需升级数据库.
| 归档时间: |
|
| 查看次数: |
1132 次 |
| 最近记录: |