按“最相关”对结果进行排序- MYSQL 和PHP

发布于 2024-09-26 15:12:54 字数 316 浏览 0 评论 0原文

我以前从未真正考虑过这个问题,想知道是否有人对实现“相关结果”的最佳实践有任何建议或意见。

就我而言,我正在运行一个搜索查询,其中包括跨 5 个字段的全文搜索、地理径向查找和一些基本比较。

对于此示例,我可以优先考虑我最感兴趣的字段。

在查找关键字 X

  • 通过地理查找过滤结果时。
  • 如果在“基本比较”中找到关键字,那么这些结果应该排在第一位。
  • 如果在“完整关键字搜索”中找到关键字,则遵循结果。

最好的方法是获取 PHP 结果数组,将其转换为对象,然后在显示之前进行比较和排序?

I've never really considered this question before and wondered if anyone has any advice or input on best practices for achieving 'relevent results'.

In my case I'm running a search query that includes full text searching across 5 fields, a geographic radial lookup and a number of basic comparisons.

I can prioritise the fields I'm most interested in for this example..

In looking for keyword X

  • Filter results by geographic lookup.
  • If keyword found in "basic comparisons" then these results should come first.
  • Then follow with results if keyword found in "full keyword search".

Would the best route be to take the PHP result array, turn this into an object and then compare and sort before displaying?

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

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

发布评论

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

评论(1

柠檬色的秋千 2024-10-03 15:12:54

您可以尝试使用 Sphinx

You can try to use Sphinx

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