Text search with multiple tables

Started by Mont Rothsteinabout 18 years ago2 messagesgeneral
Jump to latest
#1Mont Rothstein
mont.rothstein@gmail.com

Is it possible to perform a text search with tables A-->>B returning A for
matches in B?
What I want to do is to be able take columns from both A and B and perform a
search based on the keywords entered by the user that matches A, B, or both
but always returns A.

Can this be done?

Thanks,
-Mont

#2Mont Rothstein
mont.rothstein@gmail.com
In reply to: Mont Rothstein (#1)
Re: Text search with multiple tables

I found a way to do this but I don't know if there is a better way.
What I did was to create a separate index on each table and construct a
query like:

SELECT * FROM a WHERE (to_tsvector(...) @@ to_tsquery(...)) OR primaryKey IN
(SELECT distinct(foreign_key) FROM b WHERE to_tsvector(...) @@
to_tsquery(...))

Is there a better way to do this?

Thanks,
-Mont

On Thu, May 1, 2008 at 8:48 AM, Mont Rothstein <mont.rothstein@gmail.com>
wrote:

Show quoted text

Is it possible to perform a text search with tables A-->>B returning A for
matches in B?
What I want to do is to be able take columns from both A and B and perform
a search based on the keywords entered by the user that matches A, B, or
both but always returns A.

Can this be done?

Thanks,
-Mont