【问题标题】:Finding words that are close together with PostgreSQL查找与 PostgreSQL 相近的单词
【发布时间】:2015-09-30 14:49:26
【问题描述】:

有没有办法找到经常与 PostgreSQL 一起出现的单词。我知道 MySQL 在使用 proximity search 时通过 InnoDB 表支持这一点。

例子:

select quote as "Too Far Apart" 
from quotes
where match(quote) against ('"early wise" @20' in boolean mode);

【问题讨论】:

标签: mysql sql postgresql full-text-search innodb


【解决方案1】:

ts_rank_cd 提供不同的值,具体取决于术语之间的距离。

select
    ts_rank_cd( 
        to_tsvector('simple', 'the quick brown fox'), 
        plainto_tsquery('simple', 'the fox') 
    ) first,
    ts_rank_cd( 
        to_tsvector('simple', 'the quick brown fox'), 
        plainto_tsquery('simple', 'quick brown') 
    ) second;

输出:

first       second
0.0333333   0.1

0.1 / ts_rank_cd 似乎给出了单词之间的实际距离

【讨论】:

  • 谢谢。这实际上看起来是一个很好的解决方案。我会测试一下以确定。
猜你喜欢
  • 2015-08-15
  • 1970-01-01
  • 1970-01-01
  • 2010-10-11
  • 2012-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-15
相关资源
最近更新 更多