Postgres的全文搜索何时支持词组匹配和邻近匹配? [英] When will Postgres's full text search supports phrase match and proximity match?
本文介绍了Postgres的全文搜索何时支持词组匹配和邻近匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PostgreSQL 9.6文本搜索支持短语现在
选择
*
from(values
('i heart new york')) ,
('我讨厌约克新')
)docs(body)
where
to_tsvector(body)@@ phraseto_tsquery('new york')
(检索到1行)
或单词之间的距离:
- quick和fox之间恰好2hops的距离
选择
*
价值
('快速棕色狐狸'),
('quick brown cute fox')
)docs(body)
where
to_tsvector(body)@@ to_tsquery('quick 2 fox')
(检索到1行)
As of Postgres 8.4 the database fts does not support exact phrase match, nor does it support proximity match if given 2 terms. For example, there is no way to tell Postgres to match on content that have word #1 which is in a specified proximity of word #2. Any one know the plan of Postgres and possibly which version will phrase and proximity match be supported?
解决方案
PostgreSQL 9.6 text search supports phrases now
select
*
from (values
('i heart new york'),
('i hate york new')
) docs(body)
where
to_tsvector(body) @@ phraseto_tsquery('new york')
(1 row retrieved)
or by distance between words:
-- 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)
这篇关于Postgres的全文搜索何时支持词组匹配和邻近匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文