Search Postgresql Archives

Re: Fulltext index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux