MariaDB 10中的FULLTEXT索引

时间:2014-08-21 00:13:50

标签: mysql mariadb

MariaDB文档说自版本10.0.5(https://mariadb.com/kb/en/mariadb/documentation/optimization-and-tuning/optimization-and-indexes/full-text-indexes/fulltext-index-overview/)支持InnoDB的FULLTEXT索引

我最近安装了MariaDB 10.0.13并尝试将MyISAM表转换为InnoDB,如下所示:

MariaDB [(test)]> ALTER TABLE field_values ENGINE=InnoDB;

但遇到了这个错误:

ERROR 1214 (HY000): The used table type doesn't support FULLTEXT indexes

这是我的表的SHOW INDEXES查询:

MariaDB [(test)]> show indexes in  field_values;
+--------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table                    | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+--------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| field_values |          0 | PRIMARY  |            1 | productid   | A         |        NULL |     NULL | NULL   |      | BTREE      |         |               |
| field_values |          0 | PRIMARY  |            2 | fieldid     | A         |           0 |     NULL | NULL   |      | BTREE      |         |               |
| field_values |          1 | value    |            1 | value       | NULL      |        NULL |     NULL | NULL   |      | FULLTEXT   |         |               |
+--------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
3 rows in set (0.00 sec)

MariaDB文档说明了只能为CHAR,VARCHAR或TEXT列创建的索引。所以我的桌子是DESCRIBE TABLE

MariaDB [(test)]> describe  field_values ;
+-----------+-----------+------+-----+---------+-------+
| Field     | Type      | Null | Key | Default | Extra |
+-----------+-----------+------+-----+---------+-------+
| productid | int(11)   | NO   | PRI | 0       |       |
| fieldid   | int(11)   | NO   | PRI | 0       |       |
| value     | char(255) | NO   | MUL |         |       |
+-----------+-----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

支持相关字段(value),类型为CHAR

最后,这是我的MariaDB版本:

mysql  Ver 15.1 Distrib 10.0.13-MariaDB, for Linux (x86_64) using readline 5.1

因此,至少根据MariaDB文档,应该支持此操作,但我发现错误。我是否必须在MariaDB 10.0.13中启用FULLTEXT索引?

1 个答案:

答案 0 :(得分:4)

因此,在将MariaDB升级到10.0.14之后,我手动添加了全文索引,这完全正常。也许从MyIsam索引到XtraDB / InnoDB索引存在转换错误。

但应该做得好的是:

  1. 从MyIsam删除您的索引
  2. 将MariaDB升级到10.x
  3. 将MyIsam切换到InnoDB
  4. 手动添加索引
  5. 您可以在MariaDB中添加全文索引,如下所示:

    ALTER TABLE your_table ADD FULLTEXT INDEX `ft_column_name` (column_name);
    

    之后,您应该能够按预期使用您的查询。