Postgres的全文搜索何时支持词组匹配和邻近匹配? [英] When will Postgres's full text search supports phrase match and proximity match?

查看:160
本文介绍了Postgres的全文搜索何时支持词组匹配和邻近匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Postgres 8.4起,数据库fts不支持精确的词组匹配,如果给出2个词条,它也不支持近似匹配。例如,没有办法告诉Postgres匹配单词#2的内容,该单词在#2的指定接近处。任何一个人都知道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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆