diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 7b1a85fc71..f79297bb63 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -9609,6 +9609,18 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
phraseto_tsquery('english', 'The Fat Rats')
'fat' <-> 'rat'
+
+
+
+ websearch_to_tsquery
+
+ websearch_to_tsquery( config regconfig , query text)
+
+ tsquery
+ produce tsquery from a web search style query
+ websearch_to_tsquery('english', 'The Fat Rats')
+ 'fat' & 'rat'
+
diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml
index 610b7bf033..4786f362d2 100644
--- a/doc/src/sgml/textsearch.sgml
+++ b/doc/src/sgml/textsearch.sgml
@@ -797,13 +797,16 @@ UPDATE tt SET ti =
PostgreSQL provides the
functions to_tsquery,
- plainto_tsquery, and
- phraseto_tsquery
+ plainto_tsquery,
+ phraseto_tsquery and
+ websearch_to_tsquery
for converting a query to the tsquery data type.
to_tsquery offers access to more features
than either plainto_tsquery or
- phraseto_tsquery, but it is less forgiving
- about its input.
+ phraseto_tsquery, but it is less forgiving about its
+ input. websearch_to_tsquery offers the same features
+ as to_tsquery but uses an alternative syntax, similar
+ to the one used by web search engines.
@@ -962,6 +965,84 @@ SELECT phraseto_tsquery('english', 'The Fat & Rats:C');
+
+websearch_to_tsquery( config regconfig, querytext text) returns tsquery
+
+
+
+ websearch_to_tsquery creates a tsquery
+ value from querytext using an alternative
+ syntax in which simple unformatted text is a valid query.
+ Unlike plainto_tsquery
+ and phraseto_tsquery, it also recognizes certain
+ operators. The following syntax is supported:
+
+
+
+ unquoted text: text not inside quote marks will be
+ converted to terms separated by & operators, as
+ if processed by
+ plainto_tsquery.
+
+
+
+
+ "quoted text": text inside quote marks will be
+ converted to terms separated by <->
+ operators, as if processed by phraseto_tsquery.
+
+
+
+
+ AND: logical and will be converted to
+ the & operator. Not normally needed because
+ it's implicit between terms (except in quotes).
+
+
+
+
+ OR: logical or will be converted to
+ the | operator.
+
+
+
+
+ a AROUND(n) b: will match if the distance between a
+ and b is less than n.
+
+
+
+
+ -: the logical not operator, converted to the
+ the ! operator.
+
+
+
+
+
+ Examples:
+
+ select websearch_to_tsquery('The fat rats');
+ websearch_to_tsquery
+ -----------------
+ 'fat' & 'rat'
+ (1 row)
+
+
+ select websearch_to_tsquery('"supernovae stars" AND -crab');
+ websearch_to_tsquery
+ ----------------------------------
+ 'supernova' <-> 'star' & !'crab'
+ (1 row)
+
+
+ select websearch_to_tsquery('-run AROUND(5) "gnu debugger" OR "I like bananas"');
+ websearch_to_tsquery
+ -----------------------------------------------------------
+ !'run' AROUND(5) 'gnu' <-> 'debugg' | 'like' <-> 'banana'
+ (1 row)
+
+