Like plainto_tsquery
operator but allows more syntax (OR, NOT) without letting pg throws
const tsquery = require('pg-tsquery');
pool.query("SELECT * FROM tabby WHERE to_tsvector(col) @@ to_tsquery($1)", [tsquery(str)])
Examples of inputs
foo bar
isfoo&bar
foo -bar
is likefoo !bar
,foo + !bar
andfoo&!bar
foo bar,bip
is likefoo+bar | bip
andfoo&bar|bip
foo (bar,bip)
is likefoo+(bar|bip)
andfoo&(bar|bip)
Notes:
<:
are ignored- it's safe to add
:*
at the end of the result of tsquery, if it's not empty and not ending with ), for substring matching