mnoGoSearch 3.2.39 reference manual: Full-featured search engine software
Prev | Chapter 9. Miscellaneous | Next

# MySQL fulltext parser plugin

Starting with 3.2.36 mnoGoSearch offers a stemming plugin which is compatible with MySQL 5.1 pluggable fulltext parsers interface.

When mnoGoSearch stemming plugin is used as a fulltext parser plugin, all words are normalized during INSERTs, UPDATEs and SELECTs. This allows finding different grammatical forms of the same words. E.g. the search front-end will try to find the word "test" if "testing" or "tests" is given in the search query, and visa versa. During INSERTs and UPDATEs, all words are put into a fulltext index in their normalized form . During SELECTs, the query words given in MATCH operator are normalized again and then searched in the index.

To enable support for MySQL 5.1 fulltext parser plugin, mnoGoSearch must be configured with --enable-mysql-fulltext-plugin option:

    ./configure --with-mysql --enable-mysql-fulltext-plugin
    make
    make install

To install mnoGoSearch stemming plugin, libmnogosearch.so must be copied or symlinked into the MySQL plugin directory. The user issuing the "INSTALL PLUGIN" statement must have INSERT privileges for the mysql.plugin table.

    cp /usr/local/mnogosearch/lib/libmnogosearch.so /usr/lib/mysql
    or
    ln -s /usr/local/mnogosearch/lib/libmnogosearch.so /usr/lib/mysql

Before mnoGoSearch stemming plugin can be used for a fulltext index, libmnogosearch.so must be loaded into MySQL using the INSTALL PLUGIN statement:

    INSTALL PLUGIN stemming SONAME 'libmnogosearch.so';

To unload mnoGoSearch stemming plugin, use the UNINSTALL PLUGIN statement:

    UNINSTALL PLUGIN stemming;

To create an index using mnoGoSearch stemming plugin, do this:

    CREATE TABLE my_table (
      my_column TEXT,
      FULLTEXT(my_column) WITH PARSER stemming
    );

When the "INSTALL PLUGIN" statement is executed, mnoGoSearch stemming plugin reads its configuration from the file `stemming.conf` in MySQL datadir. It supports these standard mnoGoSearch commands: Affix, Spell and MinWordLength.

    MinWordLength 2
    Spell en latin1 american.xlg
    Affix en latin1 english.aff

Notes:

- mnoGoSearch stemming plugindoesn't support MySQL boolean mode operators yet.
- Whenever `stemming.conf`is modified, all fulltext indexes using the plugin most likely need to be rebuilt using "REPAIR TABLE" statement. Note that myisamchkdoes not work on tables that use plugins for fulltext indexes.
- Only one Affix and one Spell command can currently be specified in `stemming.conf`
- Using files in charsets different from column charset is not supported yet.

Usage example:

    mysql> INSTALL PLUGIN stemming SONAME 'libmnogosearch.so';
    Query OK, 0 rows affected (0.06 sec)

    mysql> CREATE TABLE t(a TEXT, FULLTEXT(a) WITH PARSER stemming);
    Query OK, 0 rows affected (0.01 sec)

    mysql> INSERT INTO t VALUES('testing'),('tested'),('test'),('tests'),('tester');
    Query OK, 5 rows affected (0.00 sec)
    Records: 5  Duplicates: 0  Warnings: 0

    mysql> SELECT * FROM t WHERE MATCH a AGAINST('test' IN BOOLEAN MODE);
    +---------+
    | a       |
    +---------+
    | testing |
    | tested  |
    | test    |
    | tests   |
    | tester  |
    +---------+
    5 rows in set (0.01 sec)

    mysql> SELECT * FROM t WHERE MATCH a AGAINST('testing' IN BOOLEAN MODE);
    +---------+
    | a       |
    +---------+
    | testing |
    | tested  |
    | test    |
    | tests   |
    | tester  |
    +---------+
    5 rows in set (0.00 sec)

Prev | Home | Next
Using libmnogosearch library | Up | Database schema