Mega Code Archive

 
Categories / MySQL / Fulltext Search
 

Noise Words

mysql> mysql> CREATE TABLE ft2(f1 VARCHAR(255),FULLTEXT(f1)); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO ft2 VALUES     ->  ('Waiting for the Barbarians'),     ->  ('In the Heart of the Country'),     ->  ('The Master of Petersburg'),     ->  ('Writing and Being'),     ->  ('Heart of the Beast'),     ->  ('Heart of the Beest'),     ->  ('The Beginning and the End'),     ->  ('Master Master'),     ->  ('A Barbarian at my Door'); Query OK, 9 rows affected (0.00 sec) Records: 9  Duplicates: 0  Warnings: 0 mysql> mysql> mysql> SELECT * FROM ft2 WHERE MATCH(f1) AGAINST ('Master'); +--------------------------+ | f1                       | +--------------------------+ | Master Master            | | The Master of Petersburg | +--------------------------+ 2 rows in set (0.00 sec) mysql> mysql> SELECT * FROM ft2 WHERE MATCH(f1) AGAINST ('The Master'); +--------------------------+ | f1                       | +--------------------------+ | Master Master            | | The Master of Petersburg | +--------------------------+ 2 rows in set (0.00 sec) mysql> mysql> mysql> SELECT * FROM ft2 WHERE MATCH(f1) AGAINST ('for'); Empty set (0.00 sec) mysql> mysql> mysql> SELECT f1, (MATCH(f1) AGAINST ('Master')) FROM ft2; +-----------------------------+--------------------------------+ | f1                          | (MATCH(f1) AGAINST ('Master')) | +-----------------------------+--------------------------------+ | Waiting for the Barbarians  |                              0 | | In the Heart of the Country |                              0 | | The Master of Petersburg    |               1.22459721565247 | | Writing and Being           |                              0 | | Heart of the Beast          |                              0 | | Heart of the Beest          |                              0 | | The Beginning and the End   |                              0 | | Master Master               |               1.23852002620697 | | A Barbarian at my Door      |                              0 | +-----------------------------+--------------------------------+ 9 rows in set (0.00 sec) mysql> mysql> SELECT f1,(MATCH(f1) AGAINST ('Master')) FROM ft2     ->  WHERE MATCH(f1) AGAINST ('Master'); +--------------------------+--------------------------------+ | f1                       | (MATCH(f1) AGAINST ('Master')) | +--------------------------+--------------------------------+ | Master Master            |               1.23852002620697 | | The Master of Petersburg |               1.22459721565247 | +--------------------------+--------------------------------+ 2 rows in set (0.00 sec) mysql> mysql> mysql> drop table ft2; Query OK, 0 rows affected (0.00 sec) mysql>