【发布时间】:2015-01-21 00:11:44
【问题描述】:
我有一张桌子,上面有一堆列 我在这样的表上创建了全文索引:
CREATE INDEX phrasetable_exp_idx ON msc.mytable
USING gin(to_tsvector('norwegian', coalesce(msc.mytable.col1,'') || ' ' ||
coalesce(msc.mytable.col2,'') || ' ' ||
coalesce(msc.mytable.col3,'') || ' ' ||
coalesce(msc.mytable.col4,'') || ' ' ||
coalesce(msc.mytable.col5,'') || ' ' ||
coalesce(msc.mytable.col6,'') || ' ' ||
coalesce(msc.mytable.col7,'')));
我尝试了一些搜索,它们的速度非常快,但是,对于一个特定的搜索,我没有得到预期的结果。 我的表中有一行 col1 和 col2 的确切值“Importkompetanse Oslo AS” 在 col3 中,它的值为“9999”。 只有查询 to_tsquery('9999') 返回该行,这表明它在 col1 和 col2 中确实具有值“Importkompetanse Oslo AS”,但前两个查询没有返回匹配项。
SELECT *
FROM msc.mytable
WHERE to_tsvector('norwegian', coalesce(msc.col1,'') || ' ' ||
coalesce(msc.mytable.col2,'') || ' ' ||
coalesce(msc.mytable.col3,'') || ' ' ||
coalesce(msc.mytable.col4,'') || ' ' ||
coalesce(msc.mytable.col5,'') || ' ' ||
coalesce(msc.mytable.col6,'') || ' ' ||
coalesce(msc.mytable.col7,'')));
@@ --to_tsquery('Importkompetanse&Oslo&AS') -- nada
plainto_tsquery('Importkompetanse') -- nada
--to_tsquery('9999') -- OK!
有人知道为什么我的搜索没有结果吗?
编辑:
由于某种原因,to_tsquery 返回如下内容: "'9999':9 'importkompetans':1,6" importkompetanse 这个词好像被删了?
但是,如果我将其设置为简单而不是挪威语,我会得到预期的结果,并且一切看起来都不错。这是为什么呢?
【问题讨论】:
标签: postgresql full-text-search full-text-indexing