mysql - 无法在 MYSQL 中为阿拉伯文本创建全文索引

标签 mysql arabic full-text-indexing

我有一个大型 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);

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

最佳答案

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

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

关于mysql - 无法在 MYSQL 中为阿拉伯文本创建全文索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55443507/

相关文章:

mysql - 复制数据库字段

iOS UIWebVIew @font-face 阿拉伯语

mysql - 警告 : A long semaphore wait

mysql - Elasticsearch 、Logstash、MySQL : how do I speed up a large import?

mysql - MySQL什么时候重建FTS索引?

php - 查询和 DB_Select 之间的 zend 转换

mysql - 优化 MySQL 选择查询以获取带有 where 子句的单个随机行

php - php 中从右到左的语言支持

java - Android ListView 中的阿拉伯文字

mysql - 当某些列具有不同的值时,将 union all 的结果合并为一行