无法在MYSQL中为阿拉伯语文本创建FULLTEXT INDEX

问题描述 投票:0回答:1

我有一个庞大的MySQL数据库。一个表'新闻'有超过600万条目。两列是阿拉伯语文本。我可以使用以下方法为这两列创建索引:

mysql> CREATE FULLTEXT INDEX news_index ON news(news_title, news_text);

但索引为空,当我尝试执行全文搜索时收到以下错误:

mysql> SELECT news_title FROM news WHERE MATCH(news_title) AGAINST('أردوغان');

ERROR 1191 (HY000): Can't find FULLTEXT index matching the column list

该数据库使用InnoDB和UTF-8。列编码是utf8_unicode_ci,我认为这可能是问题所以我将两列更改为utf8_general_ci。

当我创建索引时,索引列表显示:

+-------+------------+---------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name      | Seq_in_index | Column_name  | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+---------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| news  |          0 | PRIMARY       |            1 | news_id      | A         |     4293286 |     NULL | NULL   |      | BTREE      |         |               |
| news  |          1 | fk_news_1_idx |            1 | news_country | A         |          18 |     NULL | NULL   |      | BTREE      |         |               |
| news  |          1 | news_index    |            1 | news_title   | NULL      |     4293286 |     NULL | NULL   | YES  | FULLTEXT   |         |               |
| news  |          1 | news_index    |            2 | news_text    | NULL      |     4293286 |     NULL | NULL   | YES  | FULLTEXT   |         |               |
+-------+------------+---------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

我也试过用以下方法制作一个索引:

mysql> ALTER TABLE news ADD FULLTEXT(news_title, news_text);

但同样,没有运气。我错过了一些东西,当我创建索引时,它运行了一个多小时,所以发生了一些事情。我错过了什么?

mysql arabic full-text-indexing
1个回答
0
投票

由于您的全文索引应用于两个news_title,news_text列,因此您应该在MATCH()关键字中同时使用to

SELECT news_title FROM news WHERE MATCH(news_title,news_text) AGAINST('أردوغان');
© www.soinside.com 2019 - 2024. All rights reserved.