return rank or similarity from pg_search

194 views
Skip to first unread message

Adam Blum

unread,
Sep 1, 2012, 1:31:40 PM9/1/12
to casecom...@googlegroups.com
I have a named scope that I am using pg_search's pg_search_scope with that I would like to return a column that has rank or similarity scores.  Is there a way to do this.  The pg_search_scope gem (https://github.com/cloudcastle/pg_search_scope) has something called select_rank 
:select_rank - Include rank in select statement, as {scope_name}_rank) 

  pg_search_scope :search_descriptive,
    :against=>{:title=>'A',:description=>'B'}, 
    :using=>{:tsearch=>{:prefix=>:true,:normalization=>1},:trigram=>{}},
    :ignoring=>:accents

Adam Blum

unread,
Sep 1, 2012, 1:35:02 PM9/1/12
to casecom...@googlegroups.com
(Oops I sent that previous message before completing it - sorry.)

Anyway does pg_search have any capability of returning the rank or similarity score as a column or attribute (as pg_search_scope gem seems to).  I have an existing pg_search based named scope that works great but need to get the similarity score or ranking to do further processing with.  Below is the pg_search_scope call that I use with pg_search today.  

Any insights would be appreciated.  

Grant Hutchins

unread,
Sep 2, 2012, 11:11:59 AM9/2/12
to casecom...@googlegroups.com, casecom...@googlegroups.com
The rank already comes back as a float column called pg_search_rank

Hopefully that is exactly what you wanted! Let us know if otherwise and we can see what we can do.

Grant Hutchins
--
 
 
 
Reply all
Reply to author
Forward
0 new messages