【发布时间】:2016-12-01 14:26:01
【问题描述】:
如何将外部 JSON 模板文件加载到 ElasticSearch 中?
如何测试模板是否已正确加载?哪个 CURL 命令?
【问题讨论】:
标签: c# json elasticsearch
如何将外部 JSON 模板文件加载到 ElasticSearch 中?
如何测试模板是否已正确加载?哪个 CURL 命令?
【问题讨论】:
标签: c# json elasticsearch
是的,您可以将外部 json 模板加载到 elasticsearch 中,但在继续之前,您必须稍微格式化您的 json 模板。
{ "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 分别是索引和类型的名称。
然后使用以下 curl 命令,您可以将 json 模板上传到 elastic。
$ curl -s -XPOST localhost:9200/_bulk --data-binary @path_to_file;
我想向您指出的一件事是,如果您的 json 上传文件太大,您最终可能会结结巴巴,为此您可能需要使用一些批处理作业来调整线程池的批量上传队列大小。批量上传的默认队列大小为 50。
【讨论】: