我可以在 FULLTEXT 列的不同行中对同一单词进行不同的优先级排序吗?
我有一个网站搜索,它通过从我的 articles
表的几个字段中提取单词(name
、body
、author
、category
),并将它们全部放入具有单个 FULLTEXT 列的单独搜索表中。
我想提高搜索的准确性,以便从 name
字段中提取的单词比从 articles 的
表。body
字段中提取的相同单词具有更高的相关性
换句话说,如果文章 1 的 name
字段包含“Foo”一次,而文章 2 的 body
字段包含“Foo”两次,则文章 1 仍然会更相关。
有办法做到这一点吗?我不是指布尔搜索,我想将相关性附加到实际的列数据,而不是搜索字符串。
I have a site search that works by extracting words from several fields of my articles
table (name
, body
, author
, category
), and putting all of them in a separate search table with a single FULLTEXT column.
I want to improve the accuracy of the search so that words extracted from the name
field have a higher relevance than the same words extracted from the body
field of the articles
table.
In other words, if article 1's name
field contained "Foo" once and article 2's body
field contained "Foo" twice, article 1 would still be more relevant.
Is there a way to do this? I'm not referring to boolean searching, I want to attach relevance to the actual column data, not the search string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以根据关键字的来源赋予其权重。因此,请为表中的单词指定默认权重。当您在查询中得出分数时,将该分数乘以您拥有的默认权重。
显然,您的姓名部分中的单词将具有更多的默认值。
You can attach weight to a keyword depending on from where it came. So give default weights to words in your table. And when you come up with a score in your query, multiple that score with the default weight you have.
Obviously, words from name part of your would have more default value.