content_image/835160.jpg content_image/835159.jpg
02 02 02 02 02 02 02 10 02 02 02 02 02 02 02 02 </map> </ctype> 

4. Restart the server. 

5. To employ the new collation, include it in the definition of columns that are to use it: 

## 12.10.8 ngram Full-Text Parser 

mysql> DROP TABLE IF EXISTS t1; Query OK, 0 rows affected (0.13 sec) mysql> CREATE TABLE t1 ( a TEXT CHARACTER SET latin1 COLLATE latin1_fulltext_ci, FULLTEXT INDEX(a) ) ENGINE=InnoDB; Query OK, 0 rows affected (0.47 sec) 

6. Test the collation to verify that hyphen is considered as a word character: 

mysql> INSERT INTO t1 VALUEs (’----’),(’....’),(’abcd’); Query OK, 3 rows affected (0.22 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql> SELECT * FROM t1 WHERE MATCH a AGAINST (’----’ IN BOOLEAN MODE); +------+ | a | +------+ | ---- | +------+ 1 row in set (0.00 sec) 

The built-in MySQL full-text parser uses the white space between words as a delimiter to determine where words begin and end, which is a limitation when working with ideographic languages that do not use word delimiters. To address this limitation, MySQL provides an ngram full-text parser that supports Chinese, Japanese, and Korean (CJK). The ngram full-text parser is supported for use with InnoDB  and MyISAM . 

<img src='content_image/835160.jpg'>

<img src='content_image/835159.jpg'>

## Note 

MySQL also provides a MeCab full-text parser plugin for Japanese, which tokenizes documents into meaningful words. For more information, see Section 12.10.9, “MeCab Full-Text Parser Plugin” . 

An ngram is a contiguous sequence of n  characters from a given sequence of text. The ngram parser tokenizes a sequence of text into a contiguous sequence of n  characters. For example, you can tokenize “abcd”  for different values of n  using the ngram full-text parser. 

n=1: ’a’, ’b’, ’c’, ’d’ n=2: ’ab’, ’bc’, ’cd’ n=3: ’abc’, ’bcd’ n=4: ’abcd’ 

The ngram full-text parser is a built-in server plugin. As with other built-in server plugins, it is automatically loaded when the server is started. 

The full-text search syntax described in Section 12.10, “Full-Text Search Functions”  applies to the ngram parser plugin. Differences in parsing behavior are described in this section. Full-text-related configuration options, except for minimum and maximum word length options ( innodb_ft_min_token_size , innodb_ft_max_token_size , ft_min_word_len , ft_max_word_len ) are also applicable. 

