从 Postgres 8.4 开始,数据库 fts 不支持精确短语匹配,如果给定 2 个术语,它也不支持近似匹配。例如,没有办法告诉 Postgres 匹配具有与单词 #2 指定接近度的单词 #1 的内容。有谁知道 Postgres 的计划,可能哪个版本会支持短语和邻近匹配?
最佳答案
PostgreSQL 9.6 文本搜索现在支持短语
select
*
from (values
('i heart new york'),
('i hate york new')
) docs(body)
where
to_tsvector(body) @@ phraseto_tsquery('new york')
(1 row retrieved)
或按单词之间的距离:
-- a distance of exactly 2 "hops" between "quick" and "fox"
select
*
from (values
('the quick brown fox'),
('quick brown cute fox')
) docs(body)
where
to_tsvector(body) @@ to_tsquery('quick <2> fox')
(1 row retrieved)
关于postgresql - Postgres 的全文搜索什么时候支持词组匹配和邻近匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2908712/