我在tbl_query
select * from tbl_query q where match(q.query_desc,q.query_desc_details) against ('test1' WITH QUERY EXPANSION);
发出错误
16:46:22 select * from tbl_query q where match(q.query_desc,q.query_desc_details) against ('test1' WITH QUERY EXPANSION) LIMIT 0, 1000 Error Code: 1191. Can't find FULLTEXT index matching the column list 0.078 sec
我的表就像这样
CREATE TABLE `tbl_query` (
`query_id` int(11) NOT NULL AUTO_INCREMENT,
`query_desc` text NOT NULL,
`query_desc_details` text,
PRIMARY KEY (`query_id`),
KEY `QUERY_DESC` (`query_desc`(333)) USING BTREE,
KEY `QUERY_DESC_DETAILS` (`query_desc_details`(333)) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
在数据库中,全文字边界就像
ft_max_word_len= 84
ft_min_word_len= 4
我正在搜索两栏 所以我的问题是如何为表创建全文索引?
答案 0 :(得分:50)
您创建的2
列的全文
ALTER TABLE tbl_query
ADD FULLTEXT INDEX `FullText`
(`query_desc` ASC,
`query_desc_details` ASC);
答案 1 :(得分:23)
ALTER TABLE `TableName`
ADD FULLTEXT INDEX `IndexName` (`ColumnName`);
答案 2 :(得分:9)
这会创建索引。这是你想要的吗?
ALTER TABLE table ADD FULLTEXT index_name(column1);
答案 3 :(得分:1)
添加索引
ALTER TABLE table_name ADD FULLTEXT index_name(column1, column2);
获取搜索结果
SELECT * FROM table_name WHERE MATCH(column1, column2) AGAINST('search string' IN NATURAL LANGUAGE MODE);
删除索引
ALTER TABLE table_name DROP INDEX index_name;