如何消除 MATCH/AGAINST 中对较短行的偏见?
我正在 MySQL 的 MyISAM 表中开发一个简单的搜索接口,该接口正在实现 MATCH
/AGAINST
过程。
乍一看似乎工作正常,但经过进一步检查,它似乎偏向于较短的行长度。我只能想象这是因为它给出的分数一定更高,因为单词匹配的百分比更高。
这是对我正在使用的 MySQL 数据库的查询,结果来自下面屏幕截图中的应用程序。
SELECT
report,
status,
GROUP_CONCAT(DISTINCT status) AS statuses,
GROUP_CONCAT(DISTINCT docID) AS docIDs,
GROUP_CONCAT(DISTINCT analyst) AS analysts,
GROUP_CONCAT(DISTINCT region) AS regions,
GROUP_CONCAT(DISTINCT country) AS countries,
GROUP_CONCAT(DISTINCT topic) AS topics,
GROUP_CONCAT(DISTINCT date) AS dates,
MAX(date) AS date,
MIN(date) AS mindate,
MAX(docID) AS docID,
GROUP_CONCAT(DISTINCT event) AS events,
GROUP_CONCAT(DISTINCT rule) AS rules,
GROUP_CONCAT(DISTINCT link SEPARATOR ' ') AS links,
GROUP_CONCAT(DISTINCT province) AS provinces,
MATCH (
region, country, province, topic, event
)
AGAINST (
'toxic china'
) AS score
FROM search_reports
GROUP BY report
ORDER BY score DESC
为了简单起见,在解决这个问题时,我刚刚将 AGAINST
保留为常量。目前它设置为仅搜索“有毒瓷器”。因此,一些不包含中国的结果的排名高于包含该特定搜索关键字的结果,这是出乎意料的。
I am working on a simple search interface in a MyISAM table in MySQL, that is implementing the MATCH
/AGAINST
procedures.
It seems to work alright at first glance, but upon further inspection, it appears to have a bias towards shorter row length. I can only imagine this is because the score it is given must be higher, because the percentage of words matched is higher.
Here is the query to the MySQL database that I am using, and the results are from the application in the screenshot down below.
SELECT
report,
status,
GROUP_CONCAT(DISTINCT status) AS statuses,
GROUP_CONCAT(DISTINCT docID) AS docIDs,
GROUP_CONCAT(DISTINCT analyst) AS analysts,
GROUP_CONCAT(DISTINCT region) AS regions,
GROUP_CONCAT(DISTINCT country) AS countries,
GROUP_CONCAT(DISTINCT topic) AS topics,
GROUP_CONCAT(DISTINCT date) AS dates,
MAX(date) AS date,
MIN(date) AS mindate,
MAX(docID) AS docID,
GROUP_CONCAT(DISTINCT event) AS events,
GROUP_CONCAT(DISTINCT rule) AS rules,
GROUP_CONCAT(DISTINCT link SEPARATOR ' ') AS links,
GROUP_CONCAT(DISTINCT province) AS provinces,
MATCH (
region, country, province, topic, event
)
AGAINST (
'toxic china'
) AS score
FROM search_reports
GROUP BY report
ORDER BY score DESC
For simplicity's sake, I have just left in the AGAINST
as a constant while I am working out this issue. Currently it is set to only search for 'toxic china'. Thus it is unexpected that some results that don't contain China are being ranked higher than those that do contain that particular search keyword.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想像这样尝试 IN BOOLEAN MODE:
因为这应该只是该术语的 true / false 匹配
You may want to try IN BOOLEAN MODE like so:
as this should just be a true / false match on the term