Created
May 28, 2016 12:45
-
-
Save pruet/4a212c0c64e1874aac52c3ccb86a39f4 to your computer and use it in GitHub Desktop.
Test ngram with Thai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> drop table if exists articles; | |
Query OK, 0 rows affected (0.45 sec) | |
mysql> create table articles ( | |
-> id int unsigned auto_increment not null primary key, | |
-> title varchar(200), | |
-> body text, | |
-> FULLTEXT (title, body) WITH PARSER ngram | |
-> ) engine=innodb character set utf8; | |
Query OK, 0 rows affected (1.41 sec) | |
mysql> | |
mysql> insert into articles(title, body) values ('วันนี้ฝนไม่ตก', 'วันนี้ฝนไม่ตก'); | |
Query OK, 1 row affected (0.03 sec) | |
mysql> insert into articles(title, body) values ('พรุ่งนี้แดดออก', 'พรุ่งนี้แดดออก'); | |
Query OK, 1 row affected (0.03 sec) | |
mysql> insert into articles(title, body) values ('เมื่อวานหิมะตก', 'เมื่อวานหิมะตก'); | |
Query OK, 1 row affected (0.05 sec) | |
mysql> insert into articles(title, body) values ('ปีหน้ารวย', 'ปีหน้ารวย'); | |
Query OK, 1 row affected (0.08 sec) | |
mysql> | |
mysql> | |
mysql> SELECT * FROM articles | |
-> WHERE MATCH (title,body) | |
-> AGAINST ('นี้' IN NATURAL LANGUAGE MODE); | |
+----+--------------------------------------------+--------------------------------------------+ | |
| id | title | body | | |
+----+--------------------------------------------+--------------------------------------------+ | |
| 1 | วันนี้ฝนไม่ตก | วันนี้ฝนไม่ตก | | |
| 2 | พรุ่งนี้แดดออก | พรุ่งนี้แดดออก | | |
+----+--------------------------------------------+--------------------------------------------+ | |
2 rows in set (0.03 sec) | |
mysql> drop table if exists articles; | |
Query OK, 0 rows affected (0.49 sec) | |
mysql> create table articles ( | |
-> id int unsigned auto_increment not null primary key, | |
-> title varchar(200), | |
-> body text, | |
-> FULLTEXT (title, body) #WITH PARSER ngram | |
-> ) engine=innodb character set utf8; | |
Query OK, 0 rows affected (1.80 sec) | |
mysql> | |
mysql> insert into articles(title, body) values ('วันนี้ฝนไม่ตก', 'วันนี้ฝนไม่ตก'); | |
Query OK, 1 row affected (0.03 sec) | |
mysql> insert into articles(title, body) values ('พรุ่งนี้แดดออก', 'พรุ่งนี้แดดออก'); | |
Query OK, 1 row affected (0.03 sec) | |
mysql> insert into articles(title, body) values ('เมื่อวานหิมะตก', 'เมื่อวานหิมะตก'); | |
Query OK, 1 row affected (0.04 sec) | |
mysql> insert into articles(title, body) values ('ปีหน้ารวย', 'ปีหน้ารวย'); | |
Query OK, 1 row affected (0.06 sec) | |
mysql> | |
mysql> | |
mysql> SELECT * FROM articles | |
-> WHERE MATCH (title,body) | |
-> AGAINST ('นี้' IN NATURAL LANGUAGE MODE); | |
Empty set (0.01 sec) | |
mysql> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment