Gianluca Ghettini Gianluca Ghettini - 10 months ago 61
JSON Question

How to load an external JSON template file into ElasticSearch

How to load an external JSON template file into ElasticSearch?

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


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"} }

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

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;

elastic link for bulk upload

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.

Link to threadpool queue size elastic search