I seem to be being bitten by the same bug as #2527 which was reported three years ago.
http://archives.postgresql.org/pgsql-bugs/2006-07/msg00056.php I can't find any record of it having been addressed. The bug was filed under Postrges 8.1.1; I'm on 8.3.7 on Ubuntu. The error when 07 starts with an ' x=# select to_tsquery('foo & ''07 & bar'); ERROR: syntax error in tsquery: "foo & '07 & bar" Just plain 07 works okay: x=# select to_tsquery('foo & 07 & bar'); to_tsquery ---------------------- 'foo' & '07' & 'bar' (1 row) Is there a bug, or am I misunderstanding something? Thanks