You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用curl创建ElasticSearch索引出现映射解析错误如何解决

问题排查结论
  • 你使用的是Elasticsearch 7.x及更高版本,该版本默认取消了对自定义文档类型的支持,仅保留内置的_doc单类型,你在mapping中定义的athlete属于不被支持的自定义类型,触发根因报错
  • 你使用的string字段类型早已在Elasticsearch 5.x版本被废弃,需要替换为text或者keyword类型
修复后的执行命令
curl -X PUT "http://localhost:9200/my-index-000002?pretty" -H 'Content-Type: application/json' -d'
{
   "mappings": {
      "properties": {
        "birthdate": {
         "type": "date",
         "format": "dateOptionalTime"
         },
         "location": {
             "type": "geo_point"
          },
          "name": {
             "type": "text"
          },
          "rating": {
           "type": "integer"
        },
        "sport": {
           "type": "text"
        }
      }
   }
}'
补充说明

如果name、sport字段需要做精确匹配、分组聚合或者排序操作,可以将类型替换为keyword;dateOptionalTime是当前date类型的默认支持格式,无需显式声明也可以正常使用。

内容的提问来源于stack exchange,提问作者Timothy Clotworthy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 02:06:02