Re: Identifying which column matches a full text search

From: Ryan Wallace <rywall(at)interchange(dot)ubc(dot)ca>
To: 'Richard Huxton' <dev(at)archonet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Identifying which column matches a full text search
Date: 2008-07-30 17:51:27
Message-ID: 007701c8f26c$e4a1ae10$ade50a30$@ubc.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Huxton wrote:
>
> Failing that, where I've had many (a dozen) different sources but want
> to search them all I've built a textsearch_blocks table with columns to
> identify the source and have triggers that keep it up to date.

Once you've built the text search blocks table, how do you search it? Do you
perform
twelve separate queries or can you just do one?

Ryan

Ryan Wallace wrote:
>
> UPDATE pgweb SET textsearchable_index_col =
> to_tsvector('english', coalesce(title,'') || coalesce(body,''));

> WHERE textsearchable_index_col @@ to_tsquery('create & table')

> Using this approach. Is there any way of retrieving which of the original
> two columns the match was found in?

Afraid not - you're not indexing two columns, you're indexing one:
textsearchable_index_col.

You can add up to four weights to a tsvector though, typically for
title/body matching. See chapter 12.3 for details.

Failing that, where I've had many (a dozen) different sources but want
to search them all I've built a textsearch_blocks table with columns to
identify the source and have triggers that keep it up to date.

--
Richard Huxton
Archonet Ltd
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.5.6/1579 - Release Date: 7/29/2008
6:43 AM

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2008-07-30 18:33:42 Re: Identifying which column matches a full text search
Previous Message Tom Lane 2008-07-30 17:45:18 Re: order function in aggregate