Re: ts_tovector() to_query()

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: "Severn, Chris" <chris_severn(at)chernay(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: ts_tovector() to_query()
Date: 2013-03-28 21:12:33
Message-ID: 1364505153.95344.YahooMailNeo@web162902.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Severn, Chris" <chris_severn(at)chernay(dot)com> wrote:

> I have a statement that is like this
>
> SELECT m.* FROM movies m
>   WHERE to_tsvector(m.item_title) @@ to_tsquery('Robocop|DVD|Collection')
>
> this works, but it correctly returns all the matching records
> that have any of the query items in them.
>
> What I want to do is return items that have 'Robocop' or 'Robocop
> and DVD' or 'Robocop and Collection' or 'Robocop and DVD and
> collection'
>
> is there an operator for the tsvector / tsquery relationship that
> will do this?  Or am I forced to sift through the results of the
> initial query after the fact?

SELECT m.* FROM movies m
  WHERE to_tsvector(m.item_title) @@ to_tsquery('Robocop & (DVD | Collection)')

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2013-03-28 21:13:07 Re: Money casting too liberal?
Previous Message Severn, Chris 2013-03-28 20:50:50 ts_tovector() to_query()