如何消除 MATCH/AGAINST 中对较短行的偏见?

发布于 2024-12-20 11:11:52 字数 1432 浏览 0 评论 0原文

我正在 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.

Search Results

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

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

发布评论

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

评论(1

银河中√捞星星 2024-12-27 11:11:52

您可能想像这样尝试 IN BOOLEAN MODE:

AGAINST (
        'toxic china' IN BOOLEAN MODE
)

因为这应该只是该术语的 true / false 匹配

You may want to try IN BOOLEAN MODE like so:

AGAINST (
        'toxic china' IN BOOLEAN MODE
)

as this should just be a true / false match on the term

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