Not able to retrieve rows with SQL FULLTEXT

Viewed 17

I am trying to build a table that provides the definition of various words. I want to be able to retrieve rows based on the words contained in the definition, so I setup the that column as FULLLTEXT.

But try as I may, I am unable to retrieve rows based on the words contained in their definition column.

Here is some SQL code that illustrates the issue:

DROP TABLE IF EXISTS Words;

CREATE TABLE IF NOT EXISTS `Words` (
  `word` varchar(100) NOT NULL,
  `definition` text NOT NULL,
   PRIMARY KEY (word)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `Words` ADD FULLTEXT(definition);

INSERT INTO Words
  (word, definition)
VALUES
  ('hello', 'A greeting'),
  ('world', 'The known universe')
;

SHOW INDEXES FROM Words;

SELECT SLEEP(5);
SELECT * FROM Words;
SELECT word from Words WHERE MATCH(definition) AGAINST('greeting');

The code runs without error and the SHOW INDEXES line shows that there is indeed an index called definition.

But the last SELECT line produces empty results.

0 Answers
Related