elasticsearch使用批量插入来发布JSON文件

我有以下的JSON文件

我已经使用awk来摆脱空的空间,尾随,下一行

awk -v ORS= -v OFS= '{$1=$1}1' data.json 

我在data.json的顶部添加了一个创build请求,然后是\ n和我的其余数据。

 {"create": {"_index":"socteam", "_type":"products"}} 

当我发出批量提交请求时,出现以下错误

 CURL -XPUT http://localhost:9200/_bulk { "took": 1, "errors": true, "items": [ { "create": { "_index": "socteam", "_type": "products", "_id": "AVQuGPff-1Y7OIPIJaLX", "status": 400, "error": { "type": "mapper_parsing_exception", "reason": "failed to parse", "caused_by": { "type": "not_x_content_exception", "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes" } } } } ] 

任何想法这个错误是什么意思? 我没有创build任何映射,我使用的是vanilla elasticsearch

这是一个有效载荷示例

 cat data.json | awk -v ORS= -v OFS= '{$1=$1}1' | awk -v idx=test -v type=data 'BEGIN{print "{\"create\": {\"_index\":\"" idx "\", \"_type\":\"" type"\"}}"}; {print}; END {printf "\n"}' >> $file exit 0 fi fi 

然后我用httpie把文件提交给es