1

通过如下注册标记字符创建标记器时,无法注册罗马“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","re​​ason":"[node02][192.168.115.x:9300][indices:admin/create]"}],"type ":"illegal_argument_exception","re​​ason":"未知 标记类型:'ⅹ',必须是 [symbol、private_use、paragraph_separator、start_punctuation、未分配、enclosure_mark、connector_punctuation、letter_number、other_number、math_symbol、lowercase_letter、space_separator、surrogate、 initial_quote_punctuation、decimal_digit_number、digit、other_punctuation、dash_punctuation、currency_symbol、non_spacing_mark、格式、modifier_letter、控制、uppercase_letter、other_symbol、end_punctuation、modifier_symbol、other_letter、line_separator、titlecase_letter、字母、标点符号,combining_spacing_mark,final_quote_punctuation,空格]"},"status":400}

如何将罗马数字标记为术语?

4

1 回答 1

1

错误消息明确指出您的 RomanX不是有效的token type. 错误消息还列出了 的有效选项token type,如下所示:

必须是 [symbol、private_use、paragraph_separator、start_punctuation、未分配、enclosure_mark、connector_punctuation、letter_number、other_number、math_symbol、lowercase_letter、space_separator、surrogate、initial_quote_punctuation、decimal_digit_number、digit、other_punctuation、dash_punctuation、currency_symbol、non_spacing_mark、format、modifier_letter、control 之一, uppercase_letter, other_symbol, end_punctuation, modifier_symbol, other_letter, line_separator, titlecase_letter, letter, punctuation, combine_spacing_mark, final_quote_punctuation, whitespace]

如果您参考官方 ES 文档https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html获取令牌字符,则问题出在您的语法中,那么您就可以理解它的含义意思如下:

应包含在令牌中的字符类。Elasticsearch 将根据不属于指定类的字符进行拆分。默认为 [](保留所有字符)。

在它下面再次将有效值指定为digitletter同样的链接也有一些示例,它们token_chars与有效值一起使用。

如果您在分析仪设置中替换为,X您的问题将得到解决。letter

于 2020-02-14T18:53:58.440 回答