有什么办法导入一个json文件(包含100个文档)在elasticsearch服务器。 [英] is there any way to import a json file(contains 100 documents) in elasticsearch server.?

查看:597
本文介绍了有什么办法导入一个json文件(包含100个文档)在elasticsearch服务器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么方法在elasticsearch服务器中导入JSON文件(包含100个文档)?我要将大的json文件导入es-server ..

Is there any way to import a JSON file (contains 100 documents) in elasticsearch server? I want to import a big json file into es-server..

推荐答案

您应该使用 Bulk API 。注意,您需要在每个json文档之前添加一个标题行。

You should use Bulk API. Note that you will need to add a header line before each json document.

$ cat requests
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
$ curl -s -XPOST localhost:9200/_bulk --data-binary @requests; echo
{"took":7,"items":[{"create":{"_index":"test","_type":"type1","_id":"1","_version":1,"ok":true}}]}

这篇关于有什么办法导入一个json文件(包含100个文档)在elasticsearch服务器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆