MySQL全文期间 [英] MySQL Full Text Period

查看:96
本文介绍了MySQL全文期间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张产品名称表,全文可以很好地使用,直到使用句点,例如寻找3.7电池.我尝试

I have a table of product names, and full text works great up until using a period, e.g. searching for a 3.7 battery.. i try

select .. where match(name) against ('+3.7v +battery' in boolean mode)

我看到了将句号用双引号引起来的建议,即against ('+\"3.7v\"' in boolean mode)against ('\"3.7v\"' in boolean mode)

i saw the suggestion to enclose the period in double quotes, i.e. against ('+\"3.7v\"' in boolean mode) or against ('\"3.7v\"' in boolean mode)

均未返回任何结果. 我查看了停用词的默认列表( https://dev .mysql.com/doc/refman/5.1/en/fulltext-stopwords.html ),但看不到指定的时间段.

Neither return any results. I looked at the default list of stop words (https://dev.mysql.com/doc/refman/5.1/en/fulltext-stopwords.html) and don't see period specified.

我查看了 http://dev.mysql .com/doc/refman/5.6/en/fulltext-fine-tuning.html ,看到ft_min_word_len为3,应该放在下面.

I looked at http://dev.mysql.com/doc/refman/5.6/en/fulltext-fine-tuning.html and saw ft_min_word_len is 3, which this should fit under..

有人有建议吗?

/dev.mysql.com/doc/refman/5.6/en/fulltext-natural-language.html说FULLTEXT解析器通过查找某些定界符来确定单词的开头和结尾;例如,"(空格),,"(逗号)和." (句点).

/dev.mysql.com/doc/refman/5.6/en/fulltext-natural-language.html says The FULLTEXT parser determines where words start and end by looking for certain delimiter characters; for example, " " (space), "," (comma), and "." (period).

我猜这些分隔符与停用词列表不同.有什么方法可以配置这些而不修改源代码?不幸的是,我使用的InnoDB只是最近才添加了全文功能,并且只能在5.6中为MyISAM表创建全文解析器插件.

I guess these delimiter characters are different from the list of stop words. Is there any way to configure these without modifying the source code? Unfortunately I am using InnoDB which full-text functionality was only recently added for, and full-text parser plug-ins can only be created for MyISAM tables in 5.6

推荐答案

您可以通过以下几种方法更改被视为单词字符的字符集.进行修改后,为包含任何FULLTEXT索引的每个表重建索引.假设您要将连字符('-')视为单词字符.使用以下方法之一:

You can change the set of characters that are considered word characters in several ways, as described in the following list. After making the modification, rebuild the indexes for each table that contains any FULLTEXT indexes. Suppose that you want to treat the hyphen character ('-') as a word character. Use one of these methods:

  • 修改MySQL源:在storage/myisam/ftdefs.h中,请参见true_word_char()misc_word_char()宏.将'-'添加到这些宏之一,然后重新编译MySQL.

  • Modify the MySQL source: In storage/myisam/ftdefs.h, see the true_word_char() and misc_word_char() macros. Add '-' to one of those macros and recompile MySQL.

修改字符集文件:不需要重新编译. true_word_char()宏使用字符类型"表将字母和数字与其他字符区分开. .您可以在一个字符集XML文件中编辑<ctype><map>数组的内容,以指定'-'是字母".然后将给定的字符集用于您的FULLTEXT索引.有关<ctype><map>数组格式的信息,请参见第10.3.1节字符定义".数组" .

Modify a character set file: This requires no recompilation. The true_word_char() macro uses a "character type" table to distinguish letters and numbers from other characters. . You can edit the contents of the <ctype><map> array in one of the character set XML files to specify that '-' is a "letter." Then use the given character set for your FULLTEXT indexes. For information about the <ctype><map> array format, see Section 10.3.1, "Character Definition Arrays".

为索引列使用的字符集添加新的排序规则,并更改列以使用该排序规则.有关添加排序规则的一般信息,请参见第10.4节向字符集添加排序规则" .有关全文索引的示例,请参见第12.9.7节,为全文索引添加归类" .

Add a new collation for the character set used by the indexed columns, and alter the columns to use that collation. For general information about adding collations, see Section 10.4, "Adding a Collation to a Character Set". For an example specific to full-text indexing, see Section 12.9.7, "Adding a Collation for Full-Text Indexing".

这篇关于MySQL全文期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆