{"id":56,"date":"2008-01-24T14:00:23","date_gmt":"2008-01-24T20:00:23","guid":{"rendered":"http:\/\/www.pervasivecode.com\/blog\/2008\/01\/24\/acts_as_tsearch-adjustments-needed-for-postgresql-83rc2\/"},"modified":"2008-01-24T14:00:23","modified_gmt":"2008-01-24T20:00:23","slug":"acts_as_tsearch-adjustments-needed-for-postgresql-83rc2","status":"publish","type":"post","link":"http:\/\/www.pervasivecode.com\/blog\/2008\/01\/24\/acts_as_tsearch-adjustments-needed-for-postgresql-83rc2\/","title":{"rendered":"Acts_as_tsearch adjustments needed for PostgreSQL 8.3rc2"},"content":{"rendered":"<p>Just a quick note: acts_as_tsearch needs some guidance to work with PostgreSQL 8.3 due to changes in tsearch2 integration.<br \/>\n<!--more--><br \/>\nI&#8217;m pretty close to tossing out acts_as_tsearch and rolling my own (trigger-based) tsearch2 plugin, but for now I&#8217;m just sticking with it and checking out the PostgreSQL 8.3 release candidate.<\/p>\n<p>I was able to build 8.3rc2 on Mac OS X 10.5.1 from the tarball sources with the instructions in the INSTALL document, no hitches whatsoever. Because I have 8.2 installed via MacPorts, there were no file conflicts (different install directories, data directories, etc.), so all I had to due was shut down the 8.2 server and start the 8.3rc2 server and it was ready to go.<\/p>\n<p>Unfortunately, acts_as_tsearch didn&#8217;t work properly the way I had used with with 8.2. The issue appears to be that the tsearch2 locale called &#8216;default&#8217; is gone, which is what acts_as_tsearch uses if you don&#8217;t specify something else. The default locale value is now located in postgresql.conf. Using that value as an explicit locale in the acts_as_tsearch declaration in my model class solved the problem. The code change looks like this:<\/p>\n<p><b>OLD:<\/b><br \/>\n<code>acts_as_tsearch :fields => [\"subject\",\"body\"]<\/code><\/p>\n<p><b>NEW:<\/b><br \/>\n<code>acts_as_tsearch :vector => {:fields => [\"subject\",\"body\"], :locale => 'pg_catalog.english'}<\/code><\/p>\n<p>Like I said, due to the fact that acts_as_tsearch is designed to hide the complexity of tsearch2, it is not well suited to my somewhat complex requirements. So, I&#8217;m ditching it in favor of custom code, which I hope to plugin-ize and release some time later. So, this change is necessary but might not be sufficient for your own project. But I hope it helps you get started on upgrading successfully.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a quick note: acts_as_tsearch needs some guidance to work with PostgreSQL 8.3 due to changes in tsearch2 integration.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,19,26,20,18],"tags":[],"class_list":["post-56","post","type-post","status-publish","format-standard","hentry","category-databases","category-postgresql","category-ruby","category-ruby-on-rails","category-sql"],"_links":{"self":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts\/56"}],"collection":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":0,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pervasivecode.com\/blog\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}