通过PHP和MySQL全文搜索和突出显示? [英] fulltext search and highlighting by PHP and MySQL?

查看:114
本文介绍了通过PHP和MySQL全文搜索和突出显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



但是它不会突出显示搜索到的关键字,



我怎样才能最有效地做到这一点?

解决方案

上面提出的解决方案需要按顺序检索整个文档搜索,替换和突出显示文本。如果文件很大,而且很多,这似乎是一个非常糟糕的主意。更好的办法是让MySQL FTS像SQLITE那样直接返回文本偏移量,然后使用索引子字符串运算符 - 这将显着提高效率。


MySQL can take care of fulltext search quite well,

but it doesn't highlight the keywords that are searched,

how can I do this most efficiently?

解决方案

The solutions posed above require retrieval of the entire document in order to search, replace, and highlight text. If the document is large, and many are, this seems like a really bad idea. Better would be for MySQL FTS to return the text offsets directly like SQLITE does, then use an indexed substring operator - that would be significantly more efficient.

这篇关于通过PHP和MySQL全文搜索和突出显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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