On Mon, 7 May 2007, Ottavio Campana wrote:
Hi, I'm trying to use tsearch2 for the first time and I'm having a problem setting up a query If I execute SELECT * from test_table where ts_desc @@ to_tsquery ('hello&world'); it works, but I'm having the problem that the string used for the query is not 'hello&world' but 'hello world', Moreover, it can have an arbitrary number of spaces between the words, so I cannot just substitute the spaces with &, because 'hello&&world' gives error. What is the safest way transform a string into a list of works "anded" together?
Don't worry, see how default parser works: postgres=# select parse('default','hello world'); parse -------------- (1,hello) (12," ") (1,world) btw, you can use plainto_tsquery for AND query =# select plainto_tsquery('hello world'); plainto_tsquery ------------------- 'hello' & 'world' (1 row) Regards, Oleg _____________________________________________________________ Oleg Bartunov, Research Scientist, Head of AstroNet (www.astronet.ru), Sternberg Astronomical Institute, Moscow University, Russia Internet: oleg@xxxxxxxxxx, http://www.sai.msu.su/~megera/ phone: +007(495)939-16-83, +007(495)939-23-83