MySQL/MariaDB 匹配字母 'a' 并且 'i' 始终为 0
MySQL/MariaDB match against letter 'a' and 'i' is always 0
我的设置:
mysql --version
mysql Ver 15.1 Distrib 10.0.20-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
和
show variables like '%ft%';
+------------------------------------------+----------------+
| Variable_name | Value |
+------------------------------------------+----------------+
| aria_force_start_after_recovery_failures | 0 |
| ft_boolean_syntax | + -><()~*:""&| |
| ft_max_word_len | 84 |
| ft_min_word_len | 1 |
| ft_query_expansion_limit | 20 |
| ft_stopword_file | (built-in) |
| innodb_ft_aux_table | |
| innodb_ft_cache_size | 8000000 |
| innodb_ft_enable_diag_print | OFF |
| innodb_ft_enable_stopword | ON |
| innodb_ft_max_token_size | 84 |
| innodb_ft_min_token_size | 0 |
| innodb_ft_num_word_optimize | 2000 |
| innodb_ft_result_cache_limit | 2000000000 |
| innodb_ft_server_stopword_table | |
| innodb_ft_sort_pll_degree | 2 |
| innodb_ft_total_cache_size | 640000000 |
| innodb_ft_user_stopword_table | |
+------------------------------------------+----------------+
我正在创建 table:
CREATE TABLE `t` (
`s` VARCHAR(32) NOT NULL,
FULLTEXT INDEX `s` (`s`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
insert into t values ('a'), ('b'), ('c');
然后运行:
select s, match(s) against('a'), match(s) against('b'), match(s) against('c') from t;
+---+-----------------------+-----------------------+-----------------------+
| s | match(s) against('a') | match(s) against('b') | match(s) against('c') |
+---+-----------------------+-----------------------+-----------------------+
| a | 0 | 0 | 0 |
| b | 0 | 0.22764469683170319 | 0 |
| c | 0 | 0 | 0.22764469683170319 |
+---+-----------------------+-----------------------+-----------------------+
为什么字母 'a' 的匹配分数是 0?
同样的问题是字母 'i',所有其他字母都按预期匹配。
show variables like '%ft%';
的结果显示来自您的数据
innodb_ft_enable_stopword | ON
因此停用词列表将发挥作用
http://dev.mysql.com/doc/refman/5.1/en/fulltext-stopwords.html
对于 innodb
我们需要将其禁用为
innodb_ft_enable_stopword = OFF
之后需要重新启动 mysql 服务器,最后重新构建索引为
repair table table_name quick
我的设置:
mysql --version
mysql Ver 15.1 Distrib 10.0.20-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
和
show variables like '%ft%';
+------------------------------------------+----------------+
| Variable_name | Value |
+------------------------------------------+----------------+
| aria_force_start_after_recovery_failures | 0 |
| ft_boolean_syntax | + -><()~*:""&| |
| ft_max_word_len | 84 |
| ft_min_word_len | 1 |
| ft_query_expansion_limit | 20 |
| ft_stopword_file | (built-in) |
| innodb_ft_aux_table | |
| innodb_ft_cache_size | 8000000 |
| innodb_ft_enable_diag_print | OFF |
| innodb_ft_enable_stopword | ON |
| innodb_ft_max_token_size | 84 |
| innodb_ft_min_token_size | 0 |
| innodb_ft_num_word_optimize | 2000 |
| innodb_ft_result_cache_limit | 2000000000 |
| innodb_ft_server_stopword_table | |
| innodb_ft_sort_pll_degree | 2 |
| innodb_ft_total_cache_size | 640000000 |
| innodb_ft_user_stopword_table | |
+------------------------------------------+----------------+
我正在创建 table:
CREATE TABLE `t` (
`s` VARCHAR(32) NOT NULL,
FULLTEXT INDEX `s` (`s`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
insert into t values ('a'), ('b'), ('c');
然后运行:
select s, match(s) against('a'), match(s) against('b'), match(s) against('c') from t;
+---+-----------------------+-----------------------+-----------------------+
| s | match(s) against('a') | match(s) against('b') | match(s) against('c') |
+---+-----------------------+-----------------------+-----------------------+
| a | 0 | 0 | 0 |
| b | 0 | 0.22764469683170319 | 0 |
| c | 0 | 0 | 0.22764469683170319 |
+---+-----------------------+-----------------------+-----------------------+
为什么字母 'a' 的匹配分数是 0?
同样的问题是字母 'i',所有其他字母都按预期匹配。
show variables like '%ft%';
的结果显示来自您的数据
innodb_ft_enable_stopword | ON
因此停用词列表将发挥作用
http://dev.mysql.com/doc/refman/5.1/en/fulltext-stopwords.html
对于 innodb
我们需要将其禁用为
innodb_ft_enable_stopword = OFF
之后需要重新启动 mysql 服务器,最后重新构建索引为
repair table table_name quick