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

Elasticsearch 8.3.3 Bulk API调用出现mapper_parsing_exception求助

问题排查与解决方案

核心错误原因

  1. Bulk API路径错误:你使用的URL localhost:9200/bulk_meta/_doc/_bulk 不符合Elasticsearch Bulk API规范,多余的/_doc会导致请求解析异常。Bulk API的正确路径格式应为 {索引名}/_bulk。
  2. shell环境换行解析问题:即使手动添加了换行符,curl的-d参数在shell环境下可能无法正确识别每行独立的JSON结构,且Bulk要求最后一行必须以换行结束。

修正后的命令

curl -X POST "localhost:9200/bulk_meta/_bulk?pretty" -H 'Content-Type: application/json' -d'
{"index": { "_id": "1"}}
{"mydoc": "index action, id 1 "}
{"index": {}}
{"mydoc": "index action, id 2"}
'

备选解决方案(避免shell换行问题)

将Bulk操作内容保存为单独的JSON文件(如bulk_data.json),使用--data-binary参数读取文件,彻底规避shell对换行的解析干扰:

bulk_data.json内容:

{"index": { "_id": "1"}}
{"mydoc": "index action, id 1 "}
{"index": {}}
{"mydoc": "index action, id 2"}

执行命令:

curl -X POST "localhost:9200/bulk_meta/_bulk?pretty" -H 'Content-Type: application/json' --data-binary @bulk_data.json

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 02:45:35