ES 中,即使 type 类型是 long ,如果插入数据时存入的是 string 类型,ES 中也会保存为 string 类型。 如果想要强制 long 类型只能保存数值,可以指定 coerce: false

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "number_one": {
        "type": "integer"
      },
      "number_two": {
        "type": "integer",
        "coerce": false
      }
    }
  }
}

此时如果插入 string 类型数据会报错