14

I'm trying to run a very simple query on my MySQL INNODB table:

SELECT * 
FROM items 
WHERE MATCH (item_title,item_description) AGAINST ('dog')

Both column item_title and item_description have a FULLTEXT index.

I keep getting this error:

Can't find FULLTEXT index matching the column list

My issue: when I query just item_title or just item_description then it works fine. But when I do both at once in 1 query, as shown above, I get that error.

Any idea what is wrong?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mr.Boon
  • 2,024
  • 7
  • 35
  • 48
  • Probably duplicate question, [here](http://stackoverflow.com/questions/1117005/mysql-full-text-search-across-multiple-tables) – ali4j Aug 25 '15 at 10:26
  • 1
    That is regarding multiple tables. I'm just querying one table. Just 2 columns. So that doesn't help me unfortunately. – Mr.Boon Aug 25 '15 at 10:47

5 Answers5

17

I might be late, just post here in case of someone get confuse :)

Run this query:

ALTER TABLE `items` ADD FULLTEXT(`item_title`,`item_description`);

Then you are able to run full-text search:

SELECT * 
FROM items 
WHERE MATCH (item_title,item_description) AGAINST ('dog')
SonDang
  • 1,468
  • 1
  • 15
  • 21
14

You need a third index:

FULLTEXT(item_title, item_description)
Rick James
  • 135,179
  • 13
  • 127
  • 222
5

If you set full-text index for individual col that works. Say

ALTER TABLE `items` ADD FULLTEXT(`item_title`);
ALTER TABLE `items` ADD FULLTEXT(`item_description`);
Calos
  • 1,783
  • 19
  • 28
1
ALTER TABLE `table_name` ADD FULLTEXT (`item_title` ,`item_description`);
    and then ( "SELECT table_name.*,
    MATCH (item_title, item_description) AGAINST ('" . $search . "') AS relevance
    FROM table_name
    WHERE MATCH (item_title, item_description) AGAINST ('" . $search . "')
    ORDER BY relevance DESC" );
1

It will need one more index, combination of both column.

ALTER TABLE items ADD FULLTEXT INDEX title_desc_index (item_title, item_description);

After that you can run your query

SELECT * FROM items WHERE MATCH (item_title,item_description) AGAINST ('dog')
Vicky P
  • 553
  • 6
  • 12