## With ngram_token_size=3 ## with MyISAM bin/mysql -uroot -S /tmp/mysql_ushastry.sock Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.25 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like '%token%'; create database if not exists test; use test; drop table if exists fts_test; CREATE TABLE fts_test( code varchar(20) NOT NULL, name varchar(80) NOT NULL, PRIMARY KEY (code), FULLTEXT KEY fx_name(name) WITH PARSER ngram ) ENGINE=myisam; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | innodb_ft_max_token_size | 84 | | innodb_ft_min_token_size | 3 | | ngram_token_size | 3 | +--------------------------+-------+ 3 rows in set (0.00 sec) mysql> create database if not exists test; Query OK, 1 row affected (0.00 sec) mysql> use test; Database changed mysql> drop table if exists fts_test; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE fts_test( -> code varchar(20) NOT NULL, -> name varchar(80) NOT NULL, -> PRIMARY KEY (code), -> FULLTEXT KEY fx_name(name) WITH PARSER ngram -> ) ENGINE=myisam; Query OK, 0 rows affected (0.00 sec) mysql> mysql> insert into fts_test values ('WEL','WELLINGTON'); insert into fts_test values ('WFD','WHITEFIELD'); insert into fts_test values ('YGL','YELGUR'); insert into fts_test values ('YNK','YELHANKA JN'); insert into fts_test values ('DLI','DELHI'); insert into fts_test values ('DAZ','DELHI AZADPUR'); Query OK, 1 row affected (0.01 sec) mysql> insert into fts_test values ('WFD','WHITEFIELD'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YGL','YELGUR'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YNK','YELHANKA JN'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DLI','DELHI'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DAZ','DELHI AZADPUR'); Query OK, 1 row affected (0.00 sec) mysql> select * from fts_test where match(name) against ('DEL' in boolean mode); +------+---------------+ | code | name | +------+---------------+ | DLI | DELHI | | DAZ | DELHI AZADPUR | +------+---------------+ 2 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('YEL' in boolean mode); +------+-------------+ | code | name | +------+-------------+ | YGL | YELGUR | | YNK | YELHANKA JN | +------+-------------+ 2 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('WEL' in boolean mode); +------+------------+ | code | name | +------+------------+ | WEL | WELLINGTON | +------+------------+ 1 row in set (0.00 sec) ## With Innodb mysql> create database if not exists test; select * from fts_test where match(name) against ('YEL' in boolean mode); select * from fts_test where match(name) against ('WEL' in booQuery OK, 1 row affected, 1 warning (0.00 sec) l ean mode);mysql> use test; Database changed mysql> drop table if exists fts_test; Query OK, 0 rows affected (0.00 sec) mysql> CREATE TABLE fts_test( -> code varchar(20) NOT NULL, -> name varchar(80) NOT NULL, -> PRIMARY KEY (code), -> FULLTEXT KEY fx_name(name) WITH PARSER ngram -> ) ENGINE=innodb; Query OK, 0 rows affected (0.02 sec) mysql> mysql> insert into fts_test values ('WEL','WELLINGTON'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('WFD','WHITEFIELD'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YGL','YELGUR'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YNK','YELHANKA JN'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DLI','DELHI'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DAZ','DELHI AZADPUR'); Query OK, 1 row affected (0.00 sec) mysql> mysql> select * from fts_test where match(name) against ('DEL' in boolean mode); Empty set (0.00 sec) mysql> select * from fts_test where match(name) against ('YEL' in boolean mode); +------+-------------+ | code | name | +------+-------------+ | YGL | YELGUR | | YNK | YELHANKA JN | +------+-------------+ 2 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('WEL' in boolean mode); +------+------------+ | code | name | +------+------------+ | WEL | WELLINGTON | +------+------------+ 1 row in set (0.00 sec) ## With ngram_token_size=2 i.e default - with myisam mysql> CREATE TABLE fts_test( -> code varchar(20) NOT NULL, -> name varchar(80) NOT NULL, -> PRIMARY KEY (code), -> FULLTEXT KEY fx_name(name) WITH PARSER ngram -> ) ENGINE=myisam; select * from fts_test where match(name) against ('DEL' in boolean mode); select * from fts_test where match(name) against ('YEL' in boolean mode); select * from fts_test where match(name) against ('WEL' in boolean mode);Query OK, 0 rows affected (0.00 sec) mysql> mysql> insert into fts_test values ('WEL','WELLINGTON'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('WFD','WHITEFIELD'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YGL','YELGUR'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YNK','YELHANKA JN'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DLI','DELHI'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DAZ','DELHI AZADPUR'); Query OK, 1 row affected (0.00 sec) mysql> mysql> select * from fts_test where match(name) against ('DEL' in boolean mode); +------+---------------+ | code | name | +------+---------------+ | WEL | WELLINGTON | | WFD | WHITEFIELD | | YGL | YELGUR | | YNK | YELHANKA JN | | DLI | DELHI | | DAZ | DELHI AZADPUR | +------+---------------+ 6 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('YEL' in boolean mode); +------+---------------+ | code | name | +------+---------------+ | WEL | WELLINGTON | | WFD | WHITEFIELD | | YGL | YELGUR | | YNK | YELHANKA JN | | DLI | DELHI | | DAZ | DELHI AZADPUR | +------+---------------+ 6 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('WEL' in boolean mode); +------+---------------+ | code | name | +------+---------------+ | WEL | WELLINGTON | | WFD | WHITEFIELD | | YGL | YELGUR | | YNK | YELHANKA JN | | DLI | DELHI | | DAZ | DELHI AZADPUR | +------+---------------+ 6 rows in set (0.00 sec) - with innodb mysql> CREATE TABLE fts_test( -> code varchar(20) NOT NULL, -> name varchar(80) NOT NULL, -> PRIMARY KEY (code), -> FULLTEXT KEY fx_name(name) WITH PARSER ngram -> ) ENGINE=innodb; Query OK, 0 rows affected (0.02 sec) mysql> mysql> insert into fts_test values ('WEL','WELLINGTON'); Query OK, 1 row affected (0.01 sec) mysql> insert into fts_test values ('WFD','WHITEFIELD'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YGL','YELGUR'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YNK','YELHANKA JN'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DLI','DELHI'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DAZ','DELHI AZADPUR'); Query OK, 1 row affected (0.00 sec) mysql> mysql> select * from fts_test where match(name) against ('DEL' in boolean mode); +------+---------------+ | code | name | +------+---------------+ | WEL | WELLINGTON | | WFD | WHITEFIELD | | YGL | YELGUR | | YNK | YELHANKA JN | | DLI | DELHI | | DAZ | DELHI AZADPUR | +------+---------------+ 6 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('YEL' in boolean mode); +------+-------------+ | code | name | +------+-------------+ | YGL | YELGUR | | YNK | YELHANKA JN | +------+-------------+ 2 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('WEL' in boolean mode); +------+------------+ | code | name | +------+------------+ | WEL | WELLINGTON | +------+------------+ 1 row in set (0.00 sec) ## Workaround is to use own stopword list for all InnoDB tables ################## we have FR Bug #84420 already for this mysql> create database test; Query OK, 1 row affected (0.00 sec) mysql> use test Database changed mysql> CREATE TABLE my_stopwords(value VARCHAR(30)) ENGINE = INNODB; Query OK, 0 rows affected (0.00 sec) mysql> SET GLOBAL innodb_ft_server_stopword_table = 'test/my_stopwords'; Query OK, 0 rows affected (0.00 sec) mysql> show variables like '%token%'; use test; drop table if exists fts_test; CREATE TABLE fts_test( code varchar(20) NOT NULL, +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | innodb_ft_max_token_size | 84 | | innodb_ft_min_token_size | 3 | | ngram_token_size | 2 | +--------------------------+-------+ 3 rows in set (0.00 sec) mysql> create database if not exists test; Query OK, 1 row affected, 1 warning (0.00 sec) mysql> use test; Database changed mysql> drop table if exists fts_test; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE fts_test( -> code varchar(20) NOT NULL, -> name varchar(80) NOT NULL, -> PRIMARY KEY (code), -> FULLTEXT KEY fx_name(name) WITH PARSER ngram -> ) ENGINE=innodb; insert into fts_test values ('WEL','WELLINGTON'); insert into fts_test values ('WFD','WHITEFIELD'); insert into fts_test values ('YGL','YELGUR'); insert into fts_test values ('YNK','YELHANKA JN'); insert into fts_test values ('DLI','DELHI'); insert into fts_test values ('DAZ','DELHI AZADPUR'); select * from fts_test where match(name) against ('DEL' in boolean mode); select * from fts_test where match(name) against ('YEL' in boolean mode); select * from fts_test where match(name) against ('WEL' in boolean mode);Query OK, 0 rows affected (0.01 sec) mysql> mysql> insert into fts_test values ('WEL','WELLINGTON'); Query OK, 1 row affected (0.01 sec) mysql> insert into fts_test values ('WFD','WHITEFIELD'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YGL','YELGUR'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('YNK','YELHANKA JN'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DLI','DELHI'); Query OK, 1 row affected (0.00 sec) mysql> insert into fts_test values ('DAZ','DELHI AZADPUR'); Query OK, 1 row affected (0.00 sec) mysql> mysql> select * from fts_test where match(name) against ('DEL' in boolean mode); +------+---------------+ | code | name | +------+---------------+ | DLI | DELHI | | DAZ | DELHI AZADPUR | +------+---------------+ 2 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('YEL' in boolean mode); +------+-------------+ | code | name | +------+-------------+ | YGL | YELGUR | | YNK | YELHANKA JN | +------+-------------+ 2 rows in set (0.00 sec) mysql> select * from fts_test where match(name) against ('WEL' in boolean mode); +------+------------+ | code | name | +------+------------+ | WEL | WELLINGTON | +------+------------+ 1 row in set (0.00 sec)