MySQL 如何在多列上创建 FULLTEXT 索引?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21551560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create FULLTEXT index on multiple columns?
提问by Pradeep Kr Kaushal
I am running the following query on tbl_query
我正在运行以下查询 tbl_query
select * from tbl_query q where match(q.query_desc,q.query_desc_details) against ('test1' WITH QUERY EXPANSION);
It's giving an error
它给出了一个错误
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
My table is like this
我的桌子是这样的
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;
In database full text words boundaries are like
在数据库全文单词边界就像
ft_max_word_len= 84
ft_min_word_len= 4
I am searching against two column.
So my question is how to create the full text index for the table?
我正在搜索两列。
所以我的问题是如何为表创建全文索引?
回答by Mad Dog Tannen
Fulltext with 2columns you create like this
全文与2您这样创建的列
ALTER TABLE tbl_query
ADD FULLTEXT INDEX `FullText`
(`query_desc` ASC, `query_desc_details` ASC);
回答by Raghunandan Krishnamurthy
ALTER TABLE `TableName`
ADD FULLTEXT INDEX `IndexName` (`ColumnName`);
回答by A Paul
This creates the index. Is this what you want?
这将创建索引。这是你想要的吗?
ALTER TABLE table ADD FULLTEXT index_name(column1, column2);

