patternsqlModerate
Search all columns as a single text per row
Viewed 0 times
columnssearchallpertextsinglerow
Problem
Like google-search or any other search-box, search "all columns as single text" is a simple and universal tool, but I not seet how to do it using
No problem if it is an extension: I need an extension that offers a full-text-search with a kind of
There are times when a formal structured query language is overkill, and the easiest way to find the right content is to perform a search, like you would with a search engine such as Google or Yahoo (...) JCR-SQL2:
Full+text+search example in other SQL engine
tsquery/tsvector tools.No problem if it is an extension: I need an extension that offers a full-text-search with a kind of
contains(,text) (the same of SELECT *) instead to concatenate each column-value.There are times when a formal structured query language is overkill, and the easiest way to find the right content is to perform a search, like you would with a search engine such as Google or Yahoo (...) JCR-SQL2:
SELECT * FROM [nt:base] WHERE CONTAINS([nt:base],'full-text-query')Full+text+search example in other SQL engine
Solution
You can cast the complete row to a string (text) and then use the built-in full text search on that result:
select *
from foo
where to_tsvector(foo::text) @@ to_tsquery('full-text-query');foo::text concatenates all columns of that table as a single large string, using the default text representation for non-text data.Code Snippets
select *
from foo
where to_tsvector(foo::text) @@ to_tsquery('full-text-query');Context
StackExchange Database Administrators Q#175468, answer score: 16
Revisions (0)
No revisions yet.