Re: tokenize string for tsearch?

Поиск
Список
Период
Сортировка
Искать
От
Oleg Bartunov
Тема
Re: tokenize string for tsearch?
Дата
в 01:43:54
Msg-id
Pine.LNX.4.64.0705080836150.12152@sn.sai.msu.ru
Ответ на
Список
Дерево обсуждения
tokenize string for tsearch? Ottavio Campana <ottavio@campana.vi.it>
Re: tokenize string for tsearch? Magnus Hagander <magnus@hagander.net>
Re: tokenize string for tsearch? Ottavio Campana <ottavio@campana.vi.it>
Re: tokenize string for tsearch? Magnus Hagander <magnus@hagander.net>
Re: tokenize string for tsearch? Ottavio Campana <ottavio@campana.vi.it>
Re: tokenize string for tsearch? Oleg Bartunov <oleg@sai.msu.su>
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@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(495)939-16-83, +007(495)939-23-83
В списке pgsql-general по дате отправления
От: Paul Lambert
Дата:
Сообщение: Re: Vacuuming
От: Oleg Bartunov
Дата:
FAQ