如何将外部JSON模板文件加载到ElasticSearch中 [英] How to load an external JSON template file into ElasticSearch

查看:1227
本文介绍了如何将外部JSON模板文件加载到ElasticSearch中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将外部JSON模板文件加载到ElasticSearch?

How to load an external JSON template file into ElasticSearch?

如何验证模板是否正确加载?哪个CURL命令?

How can I test if the template has been correctly loaded? Which CURL command?

推荐答案

是的,您可以将外部json模板加载到弹性搜索中,但在继续执行相同之前,您必须格式化您的json

yeah you can load external json templates into elasticsearch but before proceeding for the same you have to format your json template a bit.

{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value3" }
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "doc" : {"field2" : "value2"} }

如果您喜欢弹性guid作为id,您可以跳过id,其中_index和_type分别是索引和类型的名称。

You can skip id if you prefer elastic guid as id, where _index and _type is the name of the index and type respectively.

然后使用以下curl命令您可以将json模板上传到弹性。

then using the following curl command you can upload your json template to elastic.

$ curl -s -XPOST localhost:9200/_bulk --data-binary @path_to_file;

弹性链接批量上传

我想指出一件事是如果您的json上传文件太大,您可能会最终扼杀您的群集,您可能需要使用某些批处理作业来调整线程池的批量上传队列大小。批量上传的默认队列大小为50。

One thing i want to point out to you is that if your json upload file is too big, you may end up stammering your cluster , for which you may need to tune bulk upload queue size for threadpool using some batch process job.Default queue size for bulk upload is 50.

链接到线程池队列大小弹性搜索

这篇关于如何将外部JSON模板文件加载到ElasticSearch中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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