FULLTEXT MYSQL查询

时间:2016-02-06 03:41:51

标签: mysql full-text-search

我试图进行FULLTEXT查询并遇到错误。

以下是查询:

SELECT `o`.`fruits_id` 
FROM `fruits` as `o` JOIN `fruits_categories` as `oc` ON `o`.`fruits_id` = `oc`.`fruits_id` 
JOIN `categories` as `c` ON `c`.`cat_id` = `oc`.`cat_id` 
JOIN `fruits_location` as `ol` ON `o`.`fruits_id` = `ol`.`fruits_id` 
JOIN `location` as `l` ON `l`.`location_id` = `ol`.`location_id` 
JOIN `fruits_price` as `op` ON `o`.`fruits_id` = `op`.`fruits_id` 
JOIN `price` as `p` ON `p`.`price_id` = `op`.`price_id` 
WHERE ( (MATCH (o.fruits_name, o.fruits_description, o.address, o.instagram_tag) AGAINST ('apple') OR MATCH (c.cat_name) AGAINST ('apple') OR MATCH (l.location_name) AGAINST ('apple') OR MATCH (p.price_name) AGAINST ('apple') ) 
AND (MATCH (o.fruits_name, o.fruits_description, o.address, o.instagram_tag) AGAINST ('orange') OR MATCH (c.cat_name) AGAINST ('orange') OR MATCH (l.location_name) AGAINST ('orange') OR MATCH (p.price_name) AGAINST ('orange') ) ) 

在我的桌子上:

水果

FULLTEXT KEY `fruits_name` (`fruits_name`),
FULLTEXT KEY `fruits_description` (`fruits_description`),
FULLTEXT KEY `address` (`address`),
FULLTEXT KEY `instagram_tag` (`instagram_tag`)

类别

FULLTEXT KEY `cat_name` (`cat_name`)

位置

FULLTEXT KEY `location_name` (`location_name`)

FULLTEXT KEY `price_name` (`price_name`)

我收到了这个错误:

Can't find FULLTEXT index matching the column list

1 个答案:

答案 0 :(得分:1)

问题是您在水果表中单独索引字段,但是您尝试在查询中以组合方式搜索它们!删除水果表中的现有全文索引,并在这4个字段上创建新的复合索引。