1

我在 postgresql 中为全文搜索创建了一个索引。

CREATE INDEX pesquisa_idx 
ON chamado 
USING 
gin(to_tsvector('portuguese', coalesce(titulo,'') || coalesce(descricao,'')));

当我运行此查询时:

SELECT * FROM chamado WHERE to_tsvector('portuguese', titulo) @@ 'ura'

它返回给我一些行。

但是当我的参数全部大写时,不会返回任何行。例如:

SELECT * FROM chamado WHERE to_tsvector('portuguese', titulo) @@ 'URA'

当论点是“ura”时,我得到几行;当参数为“URA”时,我没有得到任何行。

为什么会这样?

4

1 回答 1

3

由于 to_tsvector() 将所有词位小写,因此在第二种情况下没有匹配项。使用 to_tsquery() 构建查询,它也会处理案例问题:

SELECT * FROM chamado WHERE to_tsvector('portuguese', titulo) @@ to_tsquery('portuguese', 'URA')
于 2013-04-30T20:45:04.687 回答