postgresql - 使用 Postgresql GIN/GiST 突出显示搜索结果

标签 postgresql full-text-search search-engine highlight

使用 Postgresql 的 GIN 或 GiST 索引时是否有内置的方法来突出显示匹配的搜索关键字?或者如果没有,有一种在 Postgresql 之外执行此操作的方法吗?

我使用的是 PHP 5.3.10 和 Postgresql 9.1.3。

所有想法都会受到赞赏。

最佳答案

查看 ts_headline 函数 ts_headline .

SELECT ts_headline('english',
  'The most common type of search
is to find all documents containing given query terms
and return them in order of their similarity to the
query.',
  to_tsquery('query & similarity'));
                        ts_headline                         
------------------------------------------------------------
 containing given <b>query</b> terms
 and return them in order of their <b>similarity</b> to the
 <b>query</b>.

关于postgresql - 使用 Postgresql GIN/GiST 突出显示搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10782365/

相关文章:

MySQL 全文反对()

PHP代码在搜索引擎中的书写问题

search - 通过 SEO 绕过 b/s

django - 如何根据 ManyToManyField 中的多个值来订购模型?

sql - 未使用 Postgres 索引

python - psycopg2.errors.ConnectionFailure : SSL SYSCALL error: EOF detected

postgresql - Yii 与 PostGis,选择经度和纬度

vim - 文本替换文件数量

string - 坚持 Apostolico-Crochemore 算法

jquery - 使 AJAX 加载的内容可供 Google 抓取