Question

I'm trying to create a fulltext search index across three columns but it's not returning any results even though it seems like it should. I've replicated the problem in a testtable with the following structure and data:

CREATE TABLE IF NOT EXISTS `testtable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `link` varchar(255) NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY (`id`),
  FULLTEXT KEY `title` (`title`,`link`,`description`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

INSERT INTO `testtable` (`id`, `title`, `link`, `description`) VALUES
(1, 'mysql article', 'domain.com/article/1', 'This is an article about MySQL'),
(2, 'some other article', 'domain.com/article/mysql-article', 'This has mysql in the link but not the title'),
(3, 'my super mysql article', 'domain.com/mysql-link', 'the keyword is not in the description'),
(4, 'okay i''m searching for something', 'domain.com', 'and it''s not in the title or description'),
(5, 'mysql article', 'mydomain.com/mysql', 'mysql is definitely written in every field');

This is the query i'm using:

select * from `testtable` where MATCH(title, link, description) AGAINST('mysql')

The phrase mysql appears in at least one column in everything except row 4, while row 5 has the phrase mysql in every single column. So at the very least it should be returning row 5. But it's returning no results.

Can anyone offer an explanation as to why this is happening?

Was it helpful?

Solution

words that are present in 50% or more of the rows are considered common and do not match.

From the Doc

That means if you look for a word that most records contain, then it will be ignored in the search.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top