当通过如下方式注册令牌字符来创建令牌化程序时,无法注册罗马字母“ X”。(测试ES版本:ES6.7,ES5.6)
"tokenizer": {
"autocomplete": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 14,
"token_chars": [
"Ⅹ"
]
}
}
错误日志是这样的
{“ error”:{“ root_cause”:[{“ type”:“ remote_transport_exception”,“ reason”:“ [node02] [192.168.115.x:9300] [indices:admin / create]”}]], “ type”:“ illegal_argument_exception”,“原因”:“ 未知token type:'ⅹ',必须为[symbol,private_use,段落分隔符,开始标点符号,未分配,封装标记,连接器标点符号,字母编号,其他编号,数学符号,小写字母,空格分隔符,替代,initial_quote_punctuation,decimal_digit_number,数字,其他标点符号,破折号,货币符号,non_spacing_mark,格式,修饰符字母,控件,大写字母,other_symbol,end_punctuation,modifier_symbol,other_letter,line_separator,titlecase_letter,字母,标点,binding_spacing_mark,final_quote_punctuation,空格]“},”状态“:400}
如何将罗马数字标记成术语?
错误消息清楚地指出您的罗马X
不是有效的token type
。错误消息还会列出token type
的有效选项,如下所示:
必须为[symbol,private_use,paragraph_separator,start_punctuation,未分配,enclosing_mark,connector_punctuation,字母数字,其他数字,数学符号,小写字母,space_separator,代理,initial_quote_punctuation,小数位数,数字,其他标点,破折号,currency_symbol,non_spacing_mark,格式,modifier_letter,控件,大写字母,其他符号,结尾标点,修饰符,other_letter,line_separator,titlecase_letter,字母,标点,binding_spacing_mark,final_quote_punctuation,空格]
问题出在语法上,如果您将官方ES文档https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html引用为令牌字符,那么您可以理解它的含义,如下所述:
应包含在令牌中的字符类。弹性搜索将分割不属于指定类别的字符。默认为[](保留所有字符)。
并在其下方再次将有效值指定为digit
,letter
,并且同一链接中有一些示例使用有效值使用token_chars
。
如果在分析仪设置中将X
替换为letter
,您的问题将得到解决。