全文搜索仅支持
InnoDB和MyISAM表。Full-text searches are supported forInnoDBandMyISAMtables only.不支持分区表的全文搜索。请参阅 第 26.6 节,“分区的限制和局限”。Full-text searches are not supported for partitioned tables. See Section 26.6, “Restrictions and Limitations on Partitioning”.
全文搜索可以与大多数多字节字符集一起使用。例外情况是,对于 Unicode,可以使用
utf8mb3或utf8mb4字符集,但不能使用ucs2字符集。尽管不能在ucs2列上使用FULLTEXT索引,但您可以对没有此类索引的ucs2列执行IN BOOLEAN MODE搜索。Full-text searches can be used with most multibyte character sets. The exception is that for Unicode, theutf8mb3orutf8mb4character set can be used, but not theucs2character set. AlthoughFULLTEXTindexes onucs2columns cannot be used, you can performIN BOOLEAN MODEsearches on aucs2column that has no such index.对
utf8mb3的说明也适用于utf8mb4,对ucs2的说明也适用于utf16、utf16le和utf32。The remarks forutf8mb3also apply toutf8mb4, and the remarks forucs2also apply toutf16,utf16le, andutf32.象形文字语言如中文和日文没有单词分隔符。因此,内置的全文解析器 无法确定这些及其他类似语言中的单词起止。Ideographic languages such as Chinese and Japanese do not have word delimiters. Therefore, the built-in full-text parser cannot determine where words begin and end in these and other such languages.
提供了一个基于字符的 ngram 全文解析器,支持中文、日文和韩文 (CJK),以及一个基于单词的 MeCab 解析器插件,支持日文,可用于
InnoDB和MyISAM表。A character-based ngram full-text parser that supports Chinese, Japanese, and Korean (CJK), and a word-based MeCab parser plugin that supports Japanese are provided for use withInnoDBandMyISAMtables.虽然支持在单个表中使用多种字符集,但
FULLTEXT索引中的所有列必须使用相同的字符集和排序规则。Although the use of multiple character sets within a single table is supported, all columns in aFULLTEXTindex must use the same character set and collation.MATCH()列表必须与表中某个FULLTEXT索引定义中的列列表完全匹配,除非该MATCH()在MyISAM表上使用IN BOOLEAN MODE。对于MyISAM表,布尔模式搜索可以在非索引列上进行,尽管它们可能会很慢。TheMATCH()column list must match exactly the column list in someFULLTEXTindex definition for the table, unless thisMATCH()isIN BOOLEAN MODEon aMyISAMtable. ForMyISAMtables, boolean-mode searches can be done on nonindexed columns, although they are likely to be slow.AGAINST()的参数必须是在查询评估期间保持不变的字符串值。例如,这排除了表列,因为表列的值可能因每行而异。The argument toAGAINST()must be a string value that is constant during query evaluation. This rules out, for example, a table column because that can differ for each row.MATCH()的参数不能使用汇总列。The argument toMATCH()cannot use a rollup column.相比非
FULLTEXT搜索,FULLTEXT搜索的索引提示更受限制。参见 第 10.9.4 节,“索引提示”。Index hints are more limited forFULLTEXTsearches than for non-FULLTEXTsearches. See Section 10.9.4, “Index Hints”.对于
InnoDB,涉及带有全文索引列的所有 DML 操作(INSERT、UPDATE、DELETE)在事务提交时处理。例如,对于INSERT操作,插入的字符串会被分词并分解为单个单词。然后在事务提交时,这些单词会被添加到全文索引表中。因此,全文搜索只会返回已提交的数据。ForInnoDB, all DML operations (INSERT,UPDATE,DELETE) involving columns with full-text indexes are processed at transaction commit time. For example, for anINSERToperation, an inserted string is tokenized and decomposed into individual words. The individual words are then added to full-text index tables when the transaction is committed. As a result, full-text searches only return committed data.“%”字符不是全文搜索支持的通配符字符。The '%' character is not a supported wildcard character for full-text searches.