MySQL 5.7 でInnoDB FULLTEXT SEARCH のパーサープラグインを独自に作れるようになってます(従来はMyISAMのみ)。
さっそく、MyISAM用の全文検索パーサプラグイン mysqlftppc-bigram をInnoDBにも対応してみた。
https://github.com/mitans02/mysqlftppc-bigram
PlanetMySQL Voting: Vote UP / Vote DOWN
23.2.4.4 Writing Full-Text Parser Plugins
MySQL 5.7 supports full-text parser plugins withMyISAM
. Full-text parser plugins are supported with InnoDB as of MySQL 5.7.3. For introductory information about full-text parser plugins, see Section 23.2.3.2, “Full-Text Parser Plugins”.
さっそく、MyISAM用の全文検索パーサプラグイン mysqlftppc-bigram をInnoDBにも対応してみた。
https://github.com/mitans02/mysqlftppc-bigram
インストール方法
$ git clone https://github.com/mitans02/mysqlftppc-bigram
$ cd mysqlftppc-bigram
$ aclocal && libtoolize --automake && automake --add-missing && automake && autoconf
$ ./configure --with-mysql-config=`which mysql_config` --with-icu-config=`which icu-config`
$ make
$ sudo make install
$ mysql -uroot -p -e "install plugin bigram soname 'libftbigram.so';"
使い方
PARSER句でbigramを指定します。InnoDBなので、データ破損が許容できないケースでも使えて安心ですね!パフォーマンスはどうだろ。。。
mysql> CREATE TABLE bi (a TEXT, FULLTEXT(a) WITH PARSER bigram) CHARSET utf8 COLLATE utf8_general_ci ENGINE=InnoDB;
Query OK, 0 rows affected (0.25 sec)
mysql> SET NAMES utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO bi VALUES ("テスト"), ("こんにちは"), ("こんばんわ"), ("おはよう");
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM bi WHERE MATCH(a) AGAINST('こん' IN BOOLEAN MODE);
+-----------------+
| a |
+-----------------+
| こんにちは |
| こんばんわ |
+-----------------+
2 rows in set (0.01 sec)
PlanetMySQL Voting: Vote UP / Vote DOWN