Re: How to perform full text search

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: "Mark Phillips" <mark(dot)phillips(at)mophilly(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to perform full text search
Date: 2012-03-18 18:45:19
Message-ID: 48CFF1D3F17843C89E8C1336DFE30B21@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>Parse the entry string into words (aka tokens) and assemble with the and
>operator. E.g. 'red cat' becomes 'red & cat'. >Then add vector; more info
>in articles I provide links to later in this note.
>WHERE to_tsvector ( productname || ' ' || productdescription ) @@
>to_tsquery ( 'red & cat' )

Since there were no responces for a while, I went with another solution.
Splitted search string to words like you but converted query to

select
+case when productname ilike '%red%' then 2 else 0 end
+case when productdescription ilike '%red%' then 1 else 0 end
+case when productname ilike '%cat%' then 1.7 else 0 end
+case when productdescription ilike '%cat%' then 0.7 else 0 end
from products
order by 1 desc
limit 100

This allows to define relevance.
Is my solution reasonable ?

Andrus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2012-03-18 18:48:32 Re: How to perform full text search
Previous Message jgenoese 2012-03-18 18:41:15 Ubuntu 11.10 Postgres 9.1.3 is missing pg_resetxlog; where can I get it?