Trying to get searching working on Heroku using partial search
The following query generates an SQL error on Heroku, but works correctly in my locally version:
@events.search(params[:search]+":*")
I am using the Heroku shared database service, is this a possible difference in syntax between PostgreSQL versions?
What syntax should I be using to do a partial matching searching against a full-text index in PostgreSQL 8?
Here are the changes in PostgreSQL 9.1 .
Perhaps you could try using string interpolation instead of concatenation.
@events.search("#{params[:search]}:*")
I'm not really sure what the kiss emoticon :* adds to texticle 's functionality. Maybe I need to learn more SQL.
事实证明,PostgreSQL版本8不支持使用:*语法进行部分搜索。
As http://www.postgresql.org/docs/9.0/interactive/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES says, using ": " is for specify prefix matching. Eg If searching "Australia" with "Aus: " will work but not "ust:*".
So concat OR xxxx LIKE "%yyy%" will works better
您可以将tsearch选项与前缀一起使用:
:tsearch => {:prefix => true}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.