websearch_to_tsquery() and handling of ampersand characters insidedouble quotes

Поиск
Список
Период
Сортировка
От Alastair McKinley
Тема websearch_to_tsquery() and handling of ampersand characters insidedouble quotes
Дата
Msg-id DB6PR0202MB290450F7668104992B9D6F3CE3940@DB6PR0202MB2904.eurprd02.prod.outlook.com
обсуждение исходный текст
Список pgsql-general
Hi all,

I have recently discovered an unexpected difference in behaviour using websearch_to_tsquery() with quoted strings containing ampersands.

These two queries are equivalent without surrounding double quotes

select websearch_to_tsquery('something and another') = websearch_to_tsquery('something & another');
 ?column?
----------
 t
(1 row)

select websearch_to_tsquery('something and another');
 websearch_to_tsquery
----------------------
 'someth' & 'anoth'
(1 row)


With surrounding double quotes they produce subtly different queries, with different positional information.


 select websearch_to_tsquery('"something and another"') = websearch_to_tsquery('"something & another"');
 ?column?
----------
 f
(1 row)


select websearch_to_tsquery('"something and another"');
 websearch_to_tsquery
----------------------
 'someth' <2> 'anoth'
(1 row)

select websearch_to_tsquery('"something & another"');
 websearch_to_tsquery
----------------------
 'someth' <-> 'anoth'
(1 row)

I imagine the difference is due to the ts_vector type recording different information for the underlying strings.

select to_tsvector('something & another');
     to_tsvector      
----------------------
 'anoth':2 'someth':1
(1 row)

chimera=# select to_tsvector('something and another');
     to_tsvector      
----------------------
 'anoth':3 'someth':1
(1 row)


This leads to quite different search results and my current workaround is to suggest to users to do both searches with an OR.  Is this the right solution?

Best regards,

Alastair

В списке pgsql-general по дате отправления:

Предыдущее
От: Alastair McKinley
Дата:
Сообщение: Re: websearch_to_tsquery() and apostrophe inside double quotes
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: Is my lecturer wrong about PostgreSQL? I think he is!