diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 4dd9d02..e3479b0 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -9535,6 +9535,18 @@ CREATE TYPE rainbow AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'purple
+ websearch_to_tsquery
+
+ websearch_to_tsquery( config regconfig , query text)
+
+ tsquery
+ produce tsquery from websearch like query
+ websearch_to_tsquery('english', 'The Fat Rats')
+ 'fat' & 'rat'
+
+
+
+
querytree
querytree(query tsquery)
diff --git a/doc/src/sgml/textsearch.sgml b/doc/src/sgml/textsearch.sgml
index 4dc52ec..6f9c040 100644
--- a/doc/src/sgml/textsearch.sgml
+++ b/doc/src/sgml/textsearch.sgml
@@ -797,13 +797,15 @@ 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.
+ about its input. websearch_to_tsquery provides a different syntax,
+ similar to one used in web search engines, to create tsqeury.
@@ -960,8 +962,72 @@ SELECT phraseto_tsquery('english', 'The Fat & Rats:C');
-----------------------------
'fat' <-> 'rat' <-> 'c'
-
+
+
+
+websearch_to_tsquery( config regconfig, querytext text) returns tsquery
+
+
+ websearch_to_tsquery creates a tsquery from a unformated text.
+ But instead of plainto_tsquery and phraseto_tsquery it won't
+ ignore already placed operations. This function supports following operators:
+
+
+
+ some text - any text inside quote signs will be treated as a phrase and will be
+ performed like in phraseto_tsquery.
+
+
+
+
+ OR - standard logical operator. It is just an alias for | sign.
+
+
+
+
+ terma AROUND(N) termb - this operation will match if the distance between
+ terma and termb is less than N.
+
+
+
+
+ - - standard logical negation sign. It is an alias for ! sign.
+
+
+
+ Other missing operators will be replaced by AND like in plainto_tsquery.
+
+
+ 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)
+
+
+
+ Note that in the examples websearch_to_tsquery didn't ignore
+ operators if they were placed and put required operations
+ if they were skipped. In case of inquote text websearch_to_tsquery
+ has placed phrase operator and & in other cases.
+