websearch_to_tsquery() is a system function providing a flexible conversion from search engine-style queries to the
tsquery type for use in full text searches.
websearch_to_tsquery() was added in PostgreSQL 11.
websearch_to_tsquery ( [ config regconfig, ] query text ) → tsquery
Quoted word sequences are converted to phrase tests. The word “or” is understood as producing an OR operator, and a dash produces a NOT operator; other punctuation is ignored.
Basic usage example for
postgres=# SELECT websearch_to_tsquery('foo or bar -baz'); websearch_to_tsquery ------------------------ 'foo' | 'bar' & !'baz' (1 row)