看起来您在 MySQL 中发现了一个错误,报告错误:bugs.mysql.com。
我在 MySQL 和 MariaDB 中执行了以下脚本(没有,WITH PARSER ngram
因为目前在 MariaDB 中不支持它,请参阅Add "ngram" support to MariaDB)结果:
MySQL:
mysql> SELECT VERSION();
+--------------+
| VERSION() |
+--------------+
| 8.0.3-rc-log |
+--------------+
1 row in set (0.00 sec)
mysql> DROP TABLE IF EXISTS `title`;
Query OK, 0 rows affected (0.02 sec)
mysql> CREATE TABLE `title` (
-> `id` SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
-> `name` TEXT COLLATE utf8_unicode_ci,
-> FULLTEXT idx (`name`) -- WITH PARSER ngram
-> ) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO `title`
-> VALUES
-> (14, "I'm flying in for the game (one night in Niagara Falls, NY and one night in Buffalo then back home)."),
-> (23, "I've never been to the area."),
-> (43, "Where and what must I eat (Canadian side of Niagara, American side and Buffalo)?"),
-> (125, "Don't really have much planned other than the Falls and the game.");
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> SELECT
-> MAX(`scope`),
-> MIN(`scope`),
-> SUM(`scope`)
-> FROM
-> (
-> SELECT
-> `id`,
-> ROUND(MATCH (`name`) AGAINST ('other than the'), 2) `scope`
-> FROM `title`
-> ) `a`;
+--------------+--------------+--------------+
| MAX(`scope`) | MIN(`scope`) | SUM(`scope`) |
+--------------+--------------+--------------+
| 0.72 | 0.00 | 0.72 |
+--------------+--------------+--------------+
1 row in set (0.00 sec)
mysql> SELECT
-> `id`,
-> MAX(`scope`) OVER(),
-> MIN(`scope`) OVER(),
-> SUM(`scope`) OVER()
-> FROM
-> (
-> SELECT
-> `id`,
-> ROUND(MATCH (`name`) AGAINST ('other than the'), 2) `scope`
-> FROM `title`
-> ) `a`;
+-----+---------------------+---------------------+---------------------+
| id | MAX(`scope`) OVER() | MIN(`scope`) OVER() | SUM(`scope`) OVER() |
+-----+---------------------+---------------------+---------------------+
| 14 | 0.72 | 0.72 | 2.88 |
| 23 | 0.72 | 0.72 | 2.88 |
| 43 | 0.72 | 0.72 | 2.88 |
| 125 | 0.72 | 0.72 | 2.88 |
+-----+---------------------+---------------------+---------------------+
4 rows in set (0.00 sec)
玛丽亚数据库:
MariaDB[_]> SELECT VERSION();
+----------------------------------------+
| VERSION() |
+----------------------------------------+
| 10.2.6-MariaDB-10.2.6+maria~jessie-log |
+----------------------------------------+
1 row in set (0.00 sec)
MariaDB[_]> DROP TABLE IF EXISTS `title`;
Query OK, 0 rows affected (0.02 sec)
MariaDB[_]> CREATE TABLE `title` (
-> `id` SMALLINT UNSIGNED NOT NULL PRIMARY KEY,
-> `name` TEXT COLLATE utf8_unicode_ci,
-> FULLTEXT idx (`name`) -- WITH PARSER ngram
-> ) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.01 sec)
MariaDB[_]> INSERT INTO `title`
-> VALUES
-> (14, "I'm flying in for the game (one night in Niagara Falls, NY and one night in Buffalo then back home)."),
-> (23, "I've never been to the area."),
-> (43, "Where and what must I eat (Canadian side of Niagara, American side and Buffalo)?"),
-> (125, "Don't really have much planned other than the Falls and the game.");
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
MariaDB[_]> SELECT
-> MAX(`scope`),
-> MIN(`scope`),
-> SUM(`scope`)
-> FROM
-> (
-> SELECT
-> `id`,
-> ROUND(MATCH (`name`) AGAINST ('other than the'), 2) `scope`
-> FROM `title`
-> ) `a`;
+--------------+--------------+--------------+
| MAX(`scope`) | MIN(`scope`) | SUM(`scope`) |
+--------------+--------------+--------------+
| 0.72 | 0.00 | 0.72 |
+--------------+--------------+--------------+
1 row in set (0.00 sec)
MariaDB[_]> SELECT
-> `id`,
-> MAX(`scope`) OVER(),
-> MIN(`scope`) OVER(),
-> SUM(`scope`) OVER()
-> FROM
-> (
-> SELECT
-> `id`,
-> ROUND(MATCH (`name`) AGAINST ('other than the'), 2) `scope`
-> FROM `title`
-> ) `a`;
+-----+--------------+--------------+--------------+
| id | MAX(`scope`) | MIN(`scope`) | SUM(`scope`) |
+-----+--------------+--------------+--------------+
| 14 | 0.72 | 0.00 | 0.72 |
| 23 | 0.72 | 0.00 | 0.72 |
| 43 | 0.72 | 0.00 | 0.72 |
| 125 | 0.72 | 0.00 | 0.72 |
+-----+--------------+--------------+--------------+
4 rows in set (0.00 sec)