php 找不到与列列表匹配的 FULLTEXT 索引(已设置索引)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9680472/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 07:24:44  来源:igfitidea点击:

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

phpmysqlfull-text-search

提问by LucasRolff

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

找不到与列列表匹配的 FULLTEXT 索引

Eventho, when my table looks like this:

Eventho,当我的桌子看起来像这样时:

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

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

是因为我应该使用name代替吗?做搜索?或者可能有什么问题。

回答by jerrymouse

Assuming you are using MyISAM engine, Execute:

假设您使用的是 MyISAM 引擎,请执行:

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.

全文索引应包含与 MATCH 子句中提到的相同顺序的完全相同数量的列。

回答by karthic

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

当一切正常但仍然出现此错误时,我发现它们已KEYS被禁用。一个有时被忽视的简单错误:

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

当我禁用键时,它对我不起作用。但是当我启用键时ALTER TABLE table name ENABLE KEYS;它工作正常

回答by Chogo

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:

如果您不想让列的顺序与匹配子句中的顺序相同(或相同的数字),您可以始终使用“OR”,即:

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)

回答by jorr-el

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.

我发现我还需要在我的实例上执行此操作,因为索引不可见。这是探索 MySQL Workbench 时的一个复选框。虽然不可见,但查询无法访问索引。

ALTER TABLE products ALTER INDEX brand VISIBLE;

回答by codeafin

Make sure the table engine is set to MyISAM.

确保表引擎设置为 MyISAM。