如何按相关性对搜索结果进行排序?

发布于 2024-12-22 17:57:38 字数 363 浏览 3 评论 0原文

我正在开发一个项目,该项目搜索数据库,然后根据用户输入的字符串按相关性对搜索结果进行排序。我认为我当前的搜索相当不错,但是我编写的用于按相关性对结果进行排序的比较器给了我有趣的结果。我不知道什么是相关的。我知道这是信息检索的一个重要分支,但我不知道从哪里开始查找按相关性对对象进行排序的搜索示例,并且希望得到任何反馈。

为了提供有关我的具体问题的更多背景信息,用户将在网站数据库中输入一个字符串,该数据库存储具有各种字段的对象(商店中的商品),例如次要分类和主要分类(例如,XBox 360 游戏)可能与 Major=video_games 和 Minor=xbox360 字段及其具体名称一起存储)。我认为在搜索中应该考虑的四个主要字段是对象类型的具体名称、主要、次要和流派(如果有帮助的话)。

I'm working on a project which searches through a database, then sorts the search results by relevance, according to a string the user inputs. I think my current search is fairly decent, but the comparator I wrote to sort the results by relevance is giving me funny results. I don’t know what to consider relevant. I know this is a big branch of information retrieval, but I have no idea where to start finding examples of searches which sort objects by relevance and would appreciate any feedback.

To give a little more background about my specific issue, the user will input a string in a website database, which stores objects (items in the store) with various fields, such as a minor and major classification (for example, an XBox 360 game might be stored with major=video_games and minor=xbox360 fields along with its specific name). The four main fields that I think should be considered in the search are the specific name, major, minor, and genre of the type of object, if that helps.

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

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

发布评论

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

评论(1

长梦不多时 2024-12-29 17:57:38

如果您不想使用 lucene/Solr,您始终可以使用距离度量来查找查询与从数据库检索的行之间的相似性。获得分数后,您可以对它们进行排序,它们将被视为按相关性排序。

这正是 lucene 幕后发生的事情。您可以使用简单的相似性度量,例如曼哈顿距离、n 维空间中的点距离等。查找 lucene 评分公式以获得更多见解。

In case you don't wanna use lucene/Solr, you can always use distance metrics to find the similarity between query and the rows retrieved from database. Once you get the score you can sort them and they will be considered as sorted by relevance.

This is what exactly happens behind the scene of lucene. You can use simple similarity metrics like manhattan distance, distance of points in n-dimensional space etc. Look for lucene scoring formula for more insight.

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