I'm trying to utilize the full text search feature of PostgreSQL, particularly when user types in some search text, I would like to display him results with an assumption that the last word is incomplete.
For that purpose the "*" wildcard character needs to be attached to the last tsquery lexeme. E.g. if the user types in
"The fat ra" the tsquery should be
'fat' & 'ra':*.
If I append the whildcart to the input string and parse it with
plainto_tsquery function then the whildcard is removed
plainto_tsquery("The fat ra" || ":*") => 'fat' & 'ra'.
Constructing a tsquery manually with
to_tsquery function requries a lot modifications to the string (such as trim spaces and other special charactures, replace spaces with the ampersand character) to make the function accept it.
Is there an easier way to do that?