Обсуждение: [GENERAL] tsquery error

Поиск
Список
Период
Сортировка

[GENERAL] tsquery error

От
Stephen Davies
Дата:
The following query give the error:

select
id,title,dtype,source,used_for,ts_headline('english',content,to_tsquery('english','
ma waterflux'),'minWords = 99, maxWords = 999') from info where  clob @@
to_tsquery('english',' ma waterflux') order by title,dtype,source,used_for;
ERROR:  syntax error in tsquery: " ma waterflux"

Remove either the "ma" or the "waterflux" and the query works.

What is causing the error?

(MA Waterflux is a product name.)

Cheers and thanks,
Stephen



Re: [GENERAL] tsquery error

От
Albe Laurenz
Дата:
Stephen Davies wrote:
> The following query give the error:
> 
> select
> id,title,dtype,source,used_for,ts_headline('english',content,to_tsquery('english','
> ma waterflux'),'minWords = 99, maxWords = 999') from info where  clob @@
> to_tsquery('english',' ma waterflux') order by title,dtype,source,used_for;
> ERROR:  syntax error in tsquery: " ma waterflux"
> 
> Remove either the "ma" or the "waterflux" and the query works.
> 
> What is causing the error?
> 
> (MA Waterflux is a product name.)

It is the fact that the string contains two words.

You would have to place an operator between the words,
probably & in that case.
(https://www.postgresql.org/docs/current/static/datatype-textsearch.html#DATATYPE-TSQUERY)

Or you use "plainto_tsquery" instead of "to_tsquery".

Yours,
Laurenz Albe