/*!70000 WITH PARSER ngram*/
It mean the syntax will only be executed when the MySQL version >= 7.0.0, so you didn't use the ngram parser at all.
In my advice, you still need to use the ngram parser, because the default full-text parser can't handle the Chinese string well (This also mentioned in the document).
I ran some tests on MySQL 5.7 & 8.0 server, got same results:
For MyISAM
X: return empty result O: return rows contain the pattern
built-in parser
IN NATURAL LANGUAGE MODE (default)
企业贷款 X
贷款 X
IN BOOLEAN MODE
企业贷款 O
贷款 X
ngram
IN NATURAL LANGUAGE MODE (default)
企业贷款 X
贷款 X
IN BOOLEAN MODE
企业贷款 O
贷款 O
For InnoDB
built-in parser
IN NATURAL LANGUAGE MODE (default)
企业贷款 O
贷款 X
IN BOOLEAN MODE
企业贷款 O
贷款 X
ngram
IN NATURAL LANGUAGE MODE (default)
企业贷款 O
贷款 O
IN BOOLEAN MODE
企业贷款 O
贷款 O
First, if you search in natural language mode, there is a 50% threshold in MyISAM engine. Both 企业贷款
and 贷款
occur in more than half of the rows, MySQL will treat them as stopwords (doc), so it return nothing.
Next, if you use the built-in parser, it causes strange results, since the parser can't process these ideographic languages well.
There are two reasons for your situation:
- Not like ngram, the built-in parser only can use some symbols (in this case, is comma) to parse a Chinese sentence. The parser only catches
企业贷款
token and doesn't catch it's sub-string 贷款
.
- The built-in parser treats a Chinese token in the same way as it treats an English token. The length of
贷款
is smaller than the minimum length of a word that considered to index (check ft_min_word_len
setting for MyISAM, innodb_ft_min_token_size
for InnoDB), so it will not be indexed even though 贷款
occurs in the keywords
field many times.