我有以下JSON 文件
我使用 awk 去除空格、尾随、下一行
awk -v ORS= -v OFS= '{$1=$1}1' data.json
Run Code Online (Sandbox Code Playgroud)
我在 data.json 的顶部添加了一个创建请求,后跟 \n 和其余数据。
{"create": {"_index":"socteam", "_type":"products"}}
Run Code Online (Sandbox Code Playgroud)
当我发出批量提交请求时,出现以下错误
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"
}
}
}
}
]
Run Code Online (Sandbox Code Playgroud)
知道这个错误是什么意思吗?我还没有创建任何映射,我正在使用 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
Run Code Online (Sandbox Code Playgroud)
然后我使用httpie将文件提交到es
归档时间: |
|
查看次数: |
2980 次 |
最近记录: |