我正在尝试在弹性搜索中插入多个 JSON 文档。我已将单个文档作为以下 curl 示例
curl --request POST \
--url 'http://localhost:9200/articles/_doc/?pretty=' \
--header 'Content-Type: application/json' \
--data '{
"topic":"python",
"title": "python tuples",
"description": "practical operations with python tuples",
"author": "test",
"date": "1-1-2019",
"views" : "100"
}'
当我尝试将批量 JSON 数组插入为以下 CURL
curl --request POST \
--url 'http://localhost:9200/articles/_bulk/?pretty=' \
--header 'Content-Type: application/json' \
--data '[{
"topic":"python",
"title": "python tuples",
"description": "practical operations with python tuples",
"author": "test",
"date": "1-1-2019",
"views" : "100"
},
{
"topic":"python",
"title": "python tuples",
"description": "practical operations with python tuples",
"author": "test2",
"date": "1-1-2019",
"views" : "100"
}]'
我收到以下错误
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Malformed action/metadata line [1], expected START_OBJECT but found [START_ARRAY]"
}
],
"type": "illegal_argument_exception",
"reason": "Malformed action/metadata line [1], expected START_OBJECT but found [START_ARRAY]"
},
"status": 400
}