Partial matches with postgresql full-text search using text on Heroku

Attempting a job search on Heroku using partial search

The following query generates an SQL error on Heroku, but it works correctly in my local version:

@events.search(params[:search]+":*") 

I use the Heroku shared database service, is this a possible syntax difference between versions of PostgreSQL?

What syntax should I use to do a partial search for full-text index matches in PostgreSQL 8?

+4
source share
4 answers

It turns out PostgreSQL version 8 does not support partial searches using the syntax: *.

+2
source

Listed below are the changes in PostgreSQL 9.1 .

Perhaps you can try using string interpolation instead of concatenation.

 @events.search("#{params[:search]}:*") 

I'm not sure the emotion of a kiss: * adds to the texticle . Maybe I need to learn more SQL.

+3
source

As http://www.postgresql.org/docs/9.0/interactive/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES says that using ":" is to indicate prefix matching. For instance. If the search "Australia" with "Aus:" will work, but not "ust: *".

So concat OR xxxx LIKE "% yyy%" will work better

+1
source

You can use the tsearch option with a prefix:

 :tsearch => {:prefix => true} 
0
source

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


All Articles