Re: Ranking search results using multiple fields in PostgreSQL fulltext search - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject Re: Ranking search results using multiple fields in PostgreSQL fulltext search
Date
Msg-id 20091012154613.433fd9f1@dawn.webthatworks.it
Whole thread Raw
In response to Ranking search results using multiple fields in PostgreSQL fulltext search  (Gaini Rajeshwar <raja.rajeshwar2006@gmail.com>)
Responses Re: Ranking search results using multiple fields in PostgreSQL fulltext search
List pgsql-general
On Mon, 12 Oct 2009 18:46:02 +0530
Gaini Rajeshwar <raja.rajeshwar2006@gmail.com> wrote:

> Hi,
> is there a way to rank the search results based on multiple fields
> in postgreSQL?
> For example,
> i have *title*, *abstract*, *summary*, *body* as fields/columns in
> my database. When user searches on *title*, i want to rank the
> results based on *title* field as well as *summary* field, where
> importance(summary) > importance(title). But the results should be
> exactly matching the terms in "title" rather than "title" OR
> "summary"

http://www.postgresql.org/docs/current/interactive/textsearch-controls.html

Basically, as you can read in the docs:
- you create a ts_vector concatenating and giving a weight the
  various fields.
- then you compare your ts_vector with
  plainto_tsquery(config, yourinput) @@
  yourpreviouslycomputedts_vector

and order by ts_rank(yourpreviouslycomputedts_vector, yourinput)
(or ts_rank_cd)


--
Ivan Sergio Borgonovo
http://www.webthatworks.it


pgsql-general by date:

Previous
From: "Naoko Reeves"
Date:
Subject: Cascading of trigger execution level
Next
From: Ivan Sergio Borgonovo
Date:
Subject: Re: Ranking search results using multiple fields in PostgreSQL fulltext search