0

多数の列にフルテキスト インデックスがあり、それらの列で MATCH AGAINST IN BOOLEAN MODE を実行して、電子メール アドレスを見つけようとしています。結果は次のとおりです。

  • "test@email.com" (引用符付き) を検索すると、クエリは正しい結果を返します
  • "a@b.com" (引用符付き) を検索すると、クエリは何も返さない

短いメール a@b.com が返されない理由と、これを解決する方法を教えてください。

私が使用しているクエリは次のとおりです。

SELECT MATCH(email, phone, title, description) AGAINST('"a@b.com"' IN BOOLEAN MODE) AS score 
FROM thetable WHERE MATCH(email, phone, title, description) 
AGAINST('"a@b.com"' IN BOOLEAN MODE) ORDER BY `status` DESC, score DESC
4

2 に答える 2

1

これは、次の 2 つの問題の組み合わせです。

  1. @は「単語の文字」であるとは見なされず、どちらも-そうではないため、検索はa@b.com実際には単語の検索になりますabcom
  2. aかつbft_min_word_len より短い

解決策は、単語の文字と見なされるようにすること@です.http://dev.mysql.com/doc/refman/5.6/en/fulltext-fine-tuning.htmlにいくつかの方法がリストされています。

最も実用的な方法は、で説明されているカスタム照合を追加することです。

http://dev.mysql.com/doc/refman/5.6/en/full-text-adding-collat​​ion.html

于 2014-12-06T12:48:48.517 に答える
0

アップデート:

a) my.cnf でft_min_word_len = 1を設定する必要があります 。

b) ショー変数の出力

ft_min_word_len                                   | 1 

c) クエリの下で起動:

mysql> SELECT name,email FROM jos_users WHERE MATCH (email) AGAINST ('a@b.com') limit 1;
 +--------+---------+
 | name   | email   |
 +--------+---------+
 | kap | a@b.com |
 +--------+---------+
 1 row in set (0.00 sec)

これが役立つことを願っています。

~K


ft_min_word_lenを変更する必要があると思います

MySQLdoc の微調整で指定されているとおり

The minimum and maximum lengths of words to be indexed are defined by the ft_min_word_len and ft_max_word_len system variables. (See Section 5.1.4, “Server System Variables”.) The default minimum value is four characters; the default maximum is version dependent. If you change either value, you must rebuild your FULLTEXT indexes. For example, if you want three-character words to be searchable, you can set the ft_min_word_len variable by putting the following lines in an option file:

[mysqld] ft_min_word_len=3 Then restart the server and rebuild your FULLTEXT indexes. Note particularly the remarks regarding myisamchk in the instructions following this list.

于 2013-04-10T06:45:01.433 に答える