Skip to content

Instantly share code, notes, and snippets.

View pruet's full-sized avatar

Pruet Boonma pruet

View GitHub Profile
CREATE TABLE t (id INT, c VARCHAR(255), FULLTEXT (c) WITH PARSER thaift_parser) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
insert into t(id, c) values(1, 'อกุศลวิตก (unwholesome thought; akusala vitaka)'), (2, 'อกุศล (unwholesome; akusala)'), (3, 'วิตก (thought; vitaka)');
select id from t where match c against ('วิตก' in boolean mode); #expect 1,3
select id from t where match c against ('อกุศล' in boolean mode); #expect 1,2
select id from t where match c against ('+วิตก +akusala' in boolean mode); #expect 1
select id from t where match c against ('+วิตก +อกุศล' in boolean mode); #expect 1
select id from t where match c against ('+วิตก akusala' in boolean mode); #expect 1,3
################# Word segmentation test #############################
DROP TABLE IF EXISTS t;
CREATE TABLE t (id INT, c VARCHAR(255), FULLTEXT (c) WITH PARSER thaift_parser) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_unicode_ci;
INSERT INTO t(id, c) VALUES
(1, 'กฎหมาย'),
(2, 'มีหมาอยู่ในบ้าน');
SELECT id, c FROM t WHERE MATCH(c) AGAINST('หมา'); # expect (2)