0
對於ELK堆棧,尤其是ES,我是全新的。 我正在嘗試導入使用Google Admin SDK API的JSON文件,並且想將其導入Elasticsearch。將Google API JSON文件導入Elasticsearch
到目前爲止,這是我的數據的JSON結構:
{
"kind": "reports#activities",
"nextPageToken": string,
"items": [
{
"kind": "audit#activity",
"id": {
"time": datetime,
"uniqueQualifier": long,
"applicationName": string,
"customerId": string
},
"actor": {
"callerType": string,
"email": string,
"profileId": long,
"key": string
},
"ownerDomain": string,
"ipAddress": string,
"events": [
{
"type": string,
"name": string,
"parameters": [
{
"name": string,
"value": string,
"intValue": long,
"boolValue": boolean
}
]
}
]
}
]
}
所以我決定先使用此命令上傳的JSON文件到ES:
curl -s -XPOST 'localhost:9200/_bulk' --data-binary @documents.json
,但我得到了一些錯誤:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [START_ARRAY]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [START_ARRAY]"},"status":400}
我該怎麼辦?
謝謝你的幫助!
感謝您的提示Val!實際上,我的JSON數據包含數組(項目[],事件[]和參數[]),所以我稍微編輯了有關索引創建的代碼,方法是將括號替換爲括號,並且工作正常! – Felz
不,你不應該這樣做,ES會爲你創建這些數組;請參見[this](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html) ) – Val