php - 显示相关内容的链接

发布于 2024-08-17 13:41:22 字数 138 浏览 5 评论 0原文

我正在寻求实现一个“youtube 相关视频”风格的相关内容系统。

我的每个页面都有 5 个标签/关键字、一个标题和一个描述。我想显示两个最相似页面的链接。

我猜测 mysql 查询是基于相关性顺序的。

非常感谢。

I am looking to implement a 'youtube related videos' style related content system.

I have 5 tags/keywords for each of my pages, a title and a description. I would like to display links to the two most similar pages.

I am guessing a mysql query based around order by relevance.

many thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对风讲故事 2024-08-24 13:41:22

您可以将标题、描述、关键字分解为标记,然后在 mysql 中对这些关键字进行全文搜索并按相关性排序。

select * from article where match(title, description, keywords)
  against ('word1 word2 word3 word4' in boolean mode)
  order by relevance desc

http://dev.mysql.com/doc/refman/ 5.0/en/fulltext-boolean.html

you can break up the title, description, keywords into tokens and then do a full text search in mysql on those keywords and order by relevance.

select * from article where match(title, description, keywords)
  against ('word1 word2 word3 word4' in boolean mode)
  order by relevance desc

http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

草莓酥 2024-08-24 13:41:22

首先,应该对关键字建立索引,以便更快地访问。

然后您可以进行全文搜索:http://en.wikipedia.org/wiki/Full_text_search
或者,您可以执行 LIKE 查询: http://www.w3schools.com/SQL/sql_like .asp

然后,根据这些结果,您只需列出相关项目的列表即可。

First, the keywords should be indexed so that it can be accessed faster.

Then you can do a fulltext search: http://en.wikipedia.org/wiki/Full_text_search
Or, you could do a LIKE query: http://www.w3schools.com/SQL/sql_like.asp

Then, with those results, you just make the list of the related items.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文