This question has been asked before here and here. I want to provide full-text support using postgreSQL via to_tsquery
. However, since escaping characters leads to complications, I think it is okay to simply filtering special characters that could provoke errors.
What are the characters I need to remove to use to_tsquery safely. So far, I have identified the following:
- Input that contains
&
,|
,:
might produce syntax errors - Input with
*
might not work as expected (to_tsquery('a*b')
produces 'b') - quotes need to be escaped
What do you suggest in order to take user input in to_tsquery
? What are other special characters I need to remove?