number_type [BIG_INTEGER] 尝试将大数保存为浮点数时没有匹配的标记

No matching token for number_type [BIG_INTEGER] when trying to save large number as float

我有下一个类型的动态模板:

    "dynamic_templates" : [
      {
        "$r_as_float" : {
          "match" : "*$r",
          "mapping" : {
            "type" : "float"
          }
        }
      }
    ]

当我尝试创建新文档时:

curl -XPOST es-1:9200/mydataspace_001001/type/276121/_create -d '
{
  "kbk$r": 17404121130190019244,
}

我收到下一个错误:

{"type":"illegal_state_exception","reason":"No matching token for number_type [BIG_INTEGER]"}

例如"kbk$r": 17404时我没有这个错误。

A float 只能采用单精度 32 位 IEEE 754 浮点数,而 17404121130190019244 超出了该限制。

您需要使用 doublelong 类型而不是 float。请参阅 different numeric types 供您使用。