Why MATCH() function is not giving results?

196 views Asked by At

I'm using MySQL 5.5.31 I wan to use MATCH() and AGAINST() functions. For it I run following queries in phpMyAdmin:

CREATE TABLE articles (
       id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
       title VARCHAR(200),
       body TEXT,
       FULLTEXT (title,body)
     ) ENGINE=MyISAM;


INSERT INTO articles (title,body) VALUES
     ('MySQL Tutorial','DBMS stands for DataBase ...'),
     ('How To Use MySQL Well','After you went through a ...'),
     ('Optimizing MySQL','In this tutorial we will show ...'),
     ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
     ('MySQL vs. YourSQL','In the following database comparison ...'),
     ('MySQL Security','When configured properly, MySQL ...');
     ('MySQL table','The database is very large');

For searching the string 'database' I run following query:

SELECT * FROM articles
     WHERE MATCH (title,body)
     AGAINST ('database' IN NATURAL LANGUAGE MODE);

It returned all the three rows from the table containing word 'database'. But when I search for other string like 'the' it's not returning me anything. It's returning null. I'm not understanding why this is happening? Also if the string to be searched is present in title column it's returning null. Can anyone clear my these two doubts please? Thanks in advance.

1

There are 1 answers

3
Mihai On

MySQL has a 4 character minimum limit for search in fulltext mode.

http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html

ft_min_word_length variable can be changed.

Here it is the full stopword list for a future reference.

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

What are stopwords? http://dev.mysql.com/doc/refman/5.1/en/fulltext-natural-language.html

Some words are ignored in full-text searches:

Words in the stopword list are ignored. A stopword is a word such as “the” or “some” that is so common that it is considered to have zero semantic value. There is a built-in stopword list, but it can be overwritten by a user-defined list.