Home > other >  MySQL query match against dont want find my text
MySQL query match against dont want find my text

Time:07-07

This is my schema:

CREATE TABLE IF NOT EXISTS `test` (
  id int(11) NOT NULL,
  title text NOT NULL,
  body text NOT NULL,
  PRIMARY KEY (`id`),
  FULLTEXT (title,body)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `test` (`id`, `title`, `body`) VALUES 
('1', 'Lorem Ipsum', 'IT,cool'), 
('2', 'Lorem Ipsum (cont)', 'Some other text.');

When I call this query it will return result:

SELECT * FROM `test` WHERE MATCH (title, body) AGAINST ('cool' IN BOOLEAN MODE);

but this not:

SELECT * FROM `test` WHERE MATCH (title, body) AGAINST ('IT' IN BOOLEAN MODE);

Here is demo http://www.sqlfiddle.com/#!9/368c12/1 .

Why? What is wrong and how to solve?

CodePudding user response:

The minimum length of the word for full-text searches as of follows : Three characters for InnoDB search indexes. Four characters for MyISAM search indexes. Stop words are words that are very common such as 'on', 'the' or 'it', appear in almost every document. These type of words are ignored during searching.

https://www.w3resource.com/mysql/mysql-full-text-search-functions.php

You should try to find your string using the LIKE operator :

SELECT * FROM test WHERE CONCAT(title, body) LIKE '%IT%';
  • Related