mysql Modify stopword list for fulltext search

旧巷老猫 提交于 2020-01-24 10:16:25

问题


I've searched a lot, it's said that I have to edit my.cnf file to change the stopword list. I renamed my-medium.cnf to my.cnf and added the ft_query_expansion_limit and ft_stopword_file conditions. I have restarted mySQL. But it is not taking effect. I dont have admin privileges.

# The MySQL server
[mysqld]
port        = 3306
socket      = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
ft_query_expansion_limit = 10
ft_stopword_file = 'D:/mysql/stopword.txt'


mysql> show variables like '%ft%';
+--------------------------+----------------+
| Variable_name            | Value          |
+--------------------------+----------------+
| ft_boolean_syntax        | + -><()~*:""&| |
| ft_max_word_len          | 84             |
| ft_min_word_len          | 4              |
| ft_query_expansion_limit | 20             |
| ft_stopword_file         | (built-in)     |
+--------------------------+----------------+
5 rows in set (0.00 sec)

What can I do to modify the stopword list?


回答1:


In my.ini text file (MySQL) :

ft_stopword_file = ""   or link an empty file "empty_stopwords.txt"
ft_min_word_len = 2 

// set your minimum length, but be aware that shorter words (3,2) will increase the query time dramatically, especially if the fulltext indexed column fields are large.

Save the file, restart the server.

The next step should be to repair the indexes with this query:

REPAIR TABLE tbl_name QUICK.

However, this will not work if you table is using InnoDB storage engine. You will have to change it to MyISAM :

ALTER TABLE t1 ENGINE = MyISAM;

So, once again:

1. Edit my.ini file and save
2. Restart your server (this cannot be done dynamically)
3. Change the table engine (if needed)  ALTER TABLE tbl_name ENGINE = MyISAM;
4. Perform repair                       REPAIR TABLE tbl_name QUICK.

Be aware that InnoDB and MyISAM have their speed differences. One read faster, other writes faster ( read more about that on the internet )



来源:https://stackoverflow.com/questions/17541265/mysql-modify-stopword-list-for-fulltext-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!