Search Postgresql Archives

Creating or modifying a tsquery from PL/pgSQL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'd like to convert a plain search string into a tsquery, much like plainto_tsquery(), but enabling prefix searches (:*) for every word.

I've come up with this:

select regexp_replace(
           plainto_tsquery('english', 'text to search')::text,
           '''(?= |$)', ''':*', 'g'
       )::tsquery;
--> 'text':* & 'search':*

Is this the best way to do it, without writing C code? Can I otherwise manipulate the tsquery data structure from PL/pgSQL without converting it to/from text? Would you recommend a different approach?

-Tobia

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux