我应该为varchar使用FULLTEXT索引吗?

时间:2013-06-06 09:30:12

标签: mysql indexing full-text-search

如果我有这样的结构:

CREATE TABLE IF NOT EXISTS `sheet` (
  `id` int(11) NOT NULL,
  `title` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
  `html` text COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `title` (`title`),
  FULLTEXT KEY `html` (`html`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

我需要像这样进行全文搜索查询:

SELECT * FROM `cms`
WHERE MATCH ( title, html) AGAINST ('+psoriasis +categorizacion' IN BOOLEAN MODE)

我应该为title添加FULLTEXT索引吗?

1 个答案:

答案 0 :(得分:2)

实际上,您应该修改/替换现有索引,使其覆盖两列(如果您使用WHERE MATCH(title, html)...,而不是`WHERE MATCH(title)... AND MATCH(html)...):

CREATE TABLE sheet (
    ...
    FULLTEXT KEY title_html (title, html)
    ...
)