簡體   English   中英

MariaDB 10中的FULLTEXT索引

[英]FULLTEXT indexes in MariaDB 10

MariaDB文檔說自版本10.0.5起支持InnoDB的FULLTEXT索引( https://mariadb.com/kb/en/mariadb/documentation/optimization-and-tuning/optimization-and-indexes/full-text-indexes/全文索引 - 概述/

我最近安裝了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索引?

因此,在將MariaDB升級到10.0.14之后,我手動添加了全文索引,這完全可以正常工作。 也許從MyIsam索引到XtraDB / InnoDB索引存在轉換錯誤。

但應該做得好的是:

  1. 從MyIsam刪除您的索引
  2. 將MariaDB升級到10.x.
  3. 將MyIsam切換到InnoDB
  4. 手動添加索引

您可以在MariaDB中添加全文索引,如下所示:

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

之后,您應該能夠按預期使用您的查詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM