首页 > 解决方案 > elasticsearch中的解析器异常

问题描述

C:\Users\vishal\Desktop>curl -s -H "Content-Type: application/x-ndjson" -XPOST "http://localhost:9200/products/_bulk" --data-binary "@products-bulk -json";

{"error":{"root_cause":[{"type":"parse_exception","re​​ason":"request body is required"}],"type":"parse_exception","re​​ason":"request body is required "},"状态":400}

标签: elasticsearch

解决方案


以这种格式修改您的批量 API 请求

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/index-name/_bulk?pretty' --data-binary @products-bulk-json

并且,确保您的 json 文件是这种格式

{"index":{}}
{"col1" : "val1"}
{"index":{}}
{"col1" : "val1"}
{"index":{}}
{"col1" : "val1"}

推荐阅读