- changed status to duplicate
PostgreSQL fulltext search broken when query string is not in proper tsquery format
Postgres full text search with query strings that are not in proper format fails. Example from documentation:
Following SQLAlchemy code (taken from "Full Text Search" section under PostgreSQL dialect docs):
select([sometable.c.text.match("search string")])
should emit following SQL:
SELECT text @@ to_tsquery('search string') FROM table
But when executing that (using real column name and table name) ends up with:
ERROR: syntax error in tsquery: "search string"
There's plainto_tsquery
function that should be used instead, when query string is not in proper format:
SELECT text @@ plainto_tsquery('search string') FROM table
My idea would be to use plainto_tsquery with column.match and introduce column.match_tsquery which ends up emitting to_tsquery SQL.
Comments (1)
-
reporter - Log in to comment
Duplicate of #3160.