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

Elasticsearch跨集群Reindex脚本执行JSON解析错误求助

Elasticsearch跨集群Reindex脚本JSON语法错误修复

你的脚本报错根本原因是JSON语法缺少必要的逗号,和引号无关,具体两处问题:

  • remote对象闭合大括号后,"index": "$n"前没有加逗号
  • source对象闭合大括号后,"dest"前没有加逗号

修正后的完整脚本:

curl -k -uelastic:"password" -H 'Content-Type:application/json' -XPOST localhost:9200/_reindex?pretty -d'{
    "source": 
    {
      "remote": 
      {
        "host": "http://10.0.1.3:9200",
        "username": "elastic",
        "password": "password"
      },
        "index": "$n"
    },
    "dest": 
    {
      "index": "$n"
    }

  }'

JSON语法要求对象内的多个键值对必须用逗号分隔,这两处逗号缺失导致Elasticsearch的JSON解析器无法正确识别结构,从而抛出了x_content_parse_exception和json_parse_exception。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 08:37:54