title: How to append prefix match to tsquery in PostgreSQL
body: <p>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.</p>
  <p>For that purpose the &quot;*&quot; wildcard character needs to be attached to the last tsquery lexeme. E.g. if the user types in <code>&quot;The fat ra&quot;</code> the tsquery should be <code>'fat' &amp; 'ra':*</code>.</p>
  <p>If I append the wildcard to the input string and parse it with <code>plainto_tsquery</code> function then the wildcard is removed <code>plainto_tsquery(&quot;The fat ra&quot; || &quot;:*&quot;) =&gt; 'fat' &amp; 'ra'</code>.</p>
  <p>Constructing a tsquery manually with <code>to_tsquery</code> function requires a lot modifications to the string (such as trim spaces and other special characters, replace spaces with the ampersand character) to make the function accept it.</p>
  <p>Is there an easier way to do that?</p>