Skip to main content

Module tsquery_parser

Module tsquery_parser 

Source
Expand description

Recursive-descent parser for PostgreSQL tsquery boolean syntax.

Supported grammar (left-recursive precedence, lowest-to-highest):

query   ::= or_expr
or_expr ::= and_expr ( '|' and_expr )*
and_expr::= not_expr ( '&' not_expr )*
not_expr::= '!' not_expr | atom
atom    ::= '(' query ')'
          | term ':*'    (prefix)
          | term         (plain)

A term is any contiguous non-operator, non-paren token.

phraseto_tsquery is handled via parse_phrase_terms — the result is always FtsQuery::Phrase, which the executor rejects with Unsupported.

Functions§

parse_phrase_terms
Build an FtsQuery::Phrase from whitespace-separated terms.
parse_tsquery
Parse a PG tsquery string into an FtsQuery tree.