Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's important to note that a simple to_tsquery(...) will not handle phrases, or prefixes, or even normalizing the input. There are plainto_tsquery(...) and phraseto_tsquery(...) methods but these don't have the same flexibility and also won't do prefixes.

If you want some normalization and prefix abilities, you can actually call to_tsvector(...) on your query input, then stitch that together into a better tsquery input.

   SELECT STRING_AGG(lexeme || ':*', ' & ') 
   FROM UNNEST(to_tsvector('testing 123'))
This will return `123:* & test:*` which can then be used for searching. Full example here: https://stackoverflow.com/questions/46122175/fulltext-search...


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: