Error retrying pg_search after initializing tsearch, trigrams

I had pg_search working on my Rails 3.2.3 application using multisearch. Then I performed the initialization provided by nertzy (by pg_search author) in this post. . Now when I run the search, I get the following error:

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. 

My view is visualized using this code:

 <%= @pg_search_documents.each do |pg_search_document| %> <%= pg_search_document.searchable.title %> <% end %> 

The rest of my setup can be found here. Any help is greatly appreciated.

+6
source share
1 answer

I also ran into this problem. Just clarify for anyone who might run into difficulties ... here's how to install the extension:

  • Create a new migration by running

     bundle exec rails g migration add_trigram_extension 
  • During the transfer, paste the following code:

     def up execute "create extension pg_trgm" end def down execute "drop extension pg_trgm" end 
  • Run migration with bundle exec rake db:migrate

This worked for me locally. Some of the extensions or configurations you can use with pg_search require newer versions of Postgres. To use certain extensions for the hero, you may need to use the dev database.

UPDATE: I understand that the hero has released updated updates, and now everyone works on the new version of pg by default. The above should work on heroku without having to update your database.

+11
source

Source: https://habr.com/ru/post/915744/


All Articles