【问题标题】:How to tokenize a Roman numeral term in ElasticSearch?如何在 ElasticSearch 中标记罗马数字术语?
【发布时间】:2020-05-28 19:29:04
【问题描述】:

通过如下注册标记字符创建标记器时,无法注册罗马“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, 段落分隔符,开始标点符号,未分配,封闭标记, connector_punctuation, letter_number, other_number, math_symbol, 小写字母、空格分隔符、代理项、 initial_quote_punctuation,decimal_digit_number,数字, other_punctuation、dash_punctuation、currency_symbol、 non_spacing_mark,格式,modifier_letter,控制,大写字母, other_symbol, end_punctuation, modifier_symbol, other_letter, line_separator、titlecase_letter、字母、标点符号、 combine_spacing_mark, final_quote_punctuation, 空格]"},"状态":400}

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

【问题讨论】:

  • 你能举个例子说明你想要达到的目标吗?

标签: elasticsearch lucene tokenize elasticsearch-analyzers


【解决方案1】:

错误消息明确指出您的罗马字母 X 不是有效的 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, 代理项, initial_quote_punctuation, decimal_digit_number, 数字, other_punctuation, dash_punctuation, currency_symbol,non_spacing_mark,格式,modifier_letter,控制, 大写字母、其他符号、结束标点符号、修饰符符号、 other_letter, line_separator, titlecase_letter, 字母, 标点, combine_spacing_mark, final_quote_punctuation, whitespace]

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

应包含在令牌中的字符类。弹性搜索 将拆分不属于指定类的字符。 默认为 [](保留所有字符)。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多