Re: Identifying which column matches a full text search

From: Richard Huxton <dev(at)archonet(dot)com>
To: Ryan Wallace <rywall(at)interchange(dot)ubc(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Identifying which column matches a full text search
Date: 2008-07-29 21:29:50
Message-ID: 488F8BCE.5090701@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Emi Lu 2008-07-30 15:08:52 Get day name(Mon, Tue... Sun) and day number (1, 2...7) from a date
Previous Message Igor Neyman 2008-07-29 19:14:12 Re: column names with - and (