Re: Fulltext index

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Fulltext index
Date: 2008-11-10 11:57:59
Message-ID: 20081110115759.GB2459@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Before waking up properly, I wrote:
> Querying is a bit awkward, but works:
>
> SELECT *
> FROM test
> WHERE tsvector_concat(
> to_tsvector('english', CASE lang WHEN 'english' THEN text ELSE '' END),
> to_tsvector('german', CASE lang WHEN 'german' THEN text ELSE '' END))
> @@ to_tsquery('english', 'hello');
>
> Putting most of the above into a query would work

That should be "Putting most of the above into a VIEW would work"! The
example would be:

CREATE VIEW test_v AS
SELECT lang, text, tsvector_concat(
to_tsvector('english', CASE lang WHEN 'english' THEN text ELSE '' END),
to_tsvector('german', CASE lang WHEN 'german' THEN text ELSE '' END))
AS tsvec
FROM test;

Allowing you to do:

SELECT lang, text
FROM test_v
WHERE tsvec @@ to_tsquery('english', 'hello');

Sam

In response to

Browse pgsql-general by date

  From Date Subject
Next Message dbalinglung 2008-11-10 12:36:16 Re: Get interval in months
Previous Message Sam Mason 2008-11-10 11:50:17 Re: Get interval in months