您需要做的是读取该JSON文件,然后使用
_bulk端点期望的格式构建一个批量请求,即,一行用于命令,一行用于文档,并用换行符分隔…冲洗并重复以下步骤每个文件:
curl -XPOST localhost:9200/your_index/_bulk -d '{"index": {"_index": "your_index", "_type": "your_type", "_id": "975463711"}}{"Amount": "480", "Quantity": "2", "Id": "975463711", "Client_Store_sk": "1109"}{"index": {"_index": "your_index", "_type": "your_type", "_id": "975463943"}}{"Amount": "2105", "Quantity": "2", "Id": "975463943", "Client_Store_sk": "1109"}... etc for all your documents'只要确保替换
your_index和
your_type你正在使用的实际索引和类型名称。
更新
请注意,可以通过删除
_index和
_type如果在URL中指定了命令行来缩短命令行。
_id如果您在映射中指定id字段的路径,也可以删除它(请注意,此功能在ES
2.0中已被弃用)。至少,
{"index":{}}对于所有文档,命令行看起来都一样,但是对于指定要执行哪种操作(在本例中index为文档),它将始终是强制性的
更新2
curl -XPOST localhost:9200/index_local/my_doc_type/_bulk --data-binary @/home/data1.json
/home/data1.json应该看起来像这样:
{"index":{}}{"Amount": "480", "Quantity": "2", "Id": "975463711", "Client_Store_sk": "1109"}{"index":{}}{"Amount": "2105", "Quantity": "2", "Id": "975463943", "Client_Store_sk": "1109"}{"index":{}}{"Amount": "2107", "Quantity": "3", "Id": "974920111", "Client_Store_sk": "1109"}


