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            |                |
+------------------------------------------+----------------+

我正在创建一个表:

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”,所有其他字母都按预期匹配。

4

1 回答 1

3

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

于 2015-06-26T13:53:19.747 回答