Postgres full text search: Multiple columns, cross table Postgres full text search: Multiple columns, cross table postgresql postgresql

Postgres full text search: Multiple columns, cross table


This is covered quite well in the PostgreSQL documentation on full-text search, which shows examples of searching multiple columns and weighting them.

See in particular controlling full-text search and manipulating documents. Ranking is also right there, in ranking search results.

You haven't really provided enough information to say much more. For searching across multiple tables you usually want to JOIN the tables then query them, or, for best performance, create a trigger-maintained materialized view that you can index and then query that.

If the tables are independent and unrelated it doesn't make tons of sense to query them in a single query; you'd usually use multiple tsearch2 queries for this. I guess it's possible that you could UNION ALL the query results then rank them, but there's no guarantee the ranking would be consistent between the two tables.