Domanda

I'm having a weird problem in a mysql query, where using MATCH-AGAINST works on some words and not on others, this is the specific query that returns 0 rows:

SELECT * from series WHERE MATCH (name_e,name_a)  AGAINST ("One");

1- I'm using utf8_general_ci, so its not a case sensitivity issue

2- Other 3 characters searches return the propper results (like "Key" for example) so its not a minimum characters issue.

Here is the Tables structure:

CREATE TABLE `series` (
`series_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`brand_id` int(10) unsigned NOT NULL,
`merchandise_id` int(10) unsigned NOT NULL,
`name_a` varchar(45) NOT NULL,
`name_e` varchar(45) NOT NULL,
`desc_a` text,
`desc_e` text,
`added_by` int(11) NOT NULL DEFAULT '4',
`approved` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`series_id`),
KEY `uniqueEntry` (`brand_id`,`name_e`),
FULLTEXT KEY `nameIndex` (`name_e`,`name_a`)
)

This is some sample data used to test:

INSERT INTO `series`(`series_id`,`brand_id`,`merchandise_id`,`name_a`,`name_e`,`desc_a`,`desc_e`,`added_by`,`approved`)
VALUES ('9', '39', '164', 'Aspire One', 'Aspire One', NULL, NULL, '4', '1');
INSERT INTO `series`(`series_id`,`brand_id`,`merchandise_id`,`name_a`,`name_e`,`desc_a`,`desc_e`,`added_by`,`approved`)
VALUES ('10', '54', '164', 'One', 'One', NULL, NULL, '4', '1');
INSERT INTO `series`(`series_id`,`brand_id`,`merchandise_id`,`name_a`,`name_e`,`desc_a`,`desc_e`,`added_by`,`approved`)
VALUES ('284', '70', '173', 'Key', 'Key', NULL, NULL, '53', '1');
È stato utile?

Soluzione

"One" is in the MySQL stopwords file.

http://dev.mysql.com/doc/refman/5.5/en/fulltext-stopwords.html

The stopwords are filtered out to prevent common words effecting results.

You can set your own stopword list using these settings: "To override the default stopword list, set the ft_stopword_file system variable." http://dev.mysql.com/doc/refman/5.5/en/fulltext-fine-tuning.html

Altri suggerimenti

try that

SELECT * from series 
WHERE name_e LIKE '%One%'
OR    name_a LIKE '%One%'

DEMO HERE

the FULLTEXT doesn't index words under 4 letters. here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top