Can't find FULLTEXT index matching the column list (indexes is set)
Asked Answered
T

5

63

I'm working with fulltext, I executed an command to add the fulltext index to multiple comments, and returned no errors, then I did:

SELECT * FROM products WHERE MATCH(`brand`) AGAINST('Skoda');

Which is in the brand column - but I get following:

Can't find FULLTEXT index matching the column list

Eventho, when my table looks like this:

FULLTEXT KEY `name` (`name`,`breadcrumb`,`description`,`brand`,`price`,`year`,`km`,`usage`,`type`)

Is it because I should use the name instead? to do the search? Or what can be wrong.

Topknot answered 13/3, 2012 at 8:21 Comment(0)
A
143

Assuming you are using MyISAM engine, Execute:

ALTER TABLE products ADD FULLTEXT(brand);

The fulltext index should contain exactly the same number of columns, in same order as mentioned in MATCH clause.

Accused answered 13/3, 2012 at 8:32 Comment(8)
@Zerpex if your problem solved then you should mark it as ansFalange
@jerrymouse, I have a doubt, suppose I have three full text columns and I want to do full text search only on two columns, how I can?Falange
Note that if you are doing match() against multiple columns, you have to have full text index covering exactly same fields.Permissive
This was helpful.. especially having the same number of columns in the same order..Armalla
I found this answer in Jan 2017. It has a very important hint: exactly the same number of columns, in same order ... I havent seen this in the MySq dev pages. This seems true also for the innoDB engine. You saved my appRaceme
@Accused That last line saved my night.Grisby
This answer didnt directly help me as far as the answer to my problem, but it did explain my issue, thank you. Very important to take note that the index and the match clause needs to match, my PRIMARY index was effectively stopping this from working in a single MATCH()Dunlop
@jerrymouse, is there any way to use spring boot annotation to do this (Altering Table) ?Subordinate
P
19

If you don't feel like having the columns in the same order as in the match clause( or the same number), you can always use 'OR' that is:

ALTER TABLE products ADD FULLTEXT(brand);
ALTER TABLE products ADD FULLTEXT(product_name);

 SELECT * FROM products WHERE MATCH(brand) AGAINST('+Skoda*' IN BOOLEAN MODE) OR MATCH(product_name) AGAINST('+productName*' IN BOOLEAN MODE)
Panicstricken answered 28/3, 2018 at 6:12 Comment(1)
Thans a lot! The " IN BOOLEAN MODE" part saved my life!Hifalutin
C
9

When everything was right and still got this error I found that the KEYS were disabled. A simple error that is sometimes overlooked:

Make sure you have enabled the keys on that table.

It didn't work for me when I had disabled the keys. But when I enabled the keys ALTER TABLE table name ENABLE KEYS; it worked fine

Cardie answered 14/2, 2014 at 6:42 Comment(0)
A
2

I found I also needed to do this on my instance as the index was not visible. It was a checkbox while exploring MySQL Workbench. While invisible the index is not reachable by a query.

ALTER TABLE products ALTER INDEX brand VISIBLE;
Austreng answered 2/3, 2020 at 21:6 Comment(0)
B
1

Make sure the table engine is set to MyISAM.

Bridgettbridgette answered 29/1, 2020 at 0:55 Comment(1)
Unnecessary: dev.mysql.com/doc/refman/5.6/en/innodb-fulltext-index.htmlDrink

© 2022 - 2024 — McMap. All rights reserved.