Is there an easy way to generate a tsquery
from a list of word prefixes?
For example, an array of {'mat', 'gra'}
would generate a tsquery
of 'mat:*&gra:*'
That could be done like this:
SELECT string_agg(s || ':*', '&')::tsquery
FROM unnest('{mat,gra}'::text[]) AS s;
string_agg
-------------------
'mat':* & 'gra':*
(1 row)