diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 4dd9d02..b4d95ed 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 + queryto_tsquery + + queryto_tsquery( config regconfig , query text) + + tsquery + produce tsquery from google like query + queryto_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..5e05985 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 + queryto_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. queryto_tsquery provides a + different, Google like syntax to create tsquery. @@ -960,8 +962,72 @@ SELECT phraseto_tsquery('english', 'The Fat & Rats:C'); ----------------------------- 'fat' <-> 'rat' <-> 'c' - + + + +queryto_tsquery( config regconfig, querytext text) returns tsquery + + + queryto_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 queryto_tsquery('The fat rats'); + queryto_tsquery + ----------------- + 'fat' & 'rat' + (1 row) + + + select queryto_tsquery('"supernovae stars" AND -crab'); + queryto_tsquery + ---------------------------------- + 'supernova' <-> 'star' & !'crab' + (1 row) + + + select queryto_tsquery('-run AROUND(5) "gnu debugger" OR "I like bananas"'); + queryto_tsquery + ----------------------------------------------------------- + !'run' AROUND(5) 'gnu' <-> 'debugg' | 'like' <-> 'banana' + (1 row) + + + + Note that in the examples queryto_tsquery didn't ignore + operators if they were placed and put required operations + if they were skipped. In case of inquote text queryto_tsquery + has placed phrase operator and & in other cases. +