【问题标题】:How to load an external JSON template file into ElasticSearch如何将外部 JSON 模板文件加载到 ElasticSearch
【发布时间】:2016-12-01 14:26:01
【问题描述】:

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

如何测试模板是否已正确加载?哪个 CURL 命令?

【问题讨论】:

    标签: c# json elasticsearch


    【解决方案1】:

    是的,您可以将外部 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;
    

    elastic link for bulk upload

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

    Link to threadpool queue size elastic search

    【讨论】:

      猜你喜欢
      • 2021-11-22
      • 1970-01-01
      • 2017-10-16
      • 2015-10-16
      • 2011-05-20
      • 1970-01-01
      • 2016-07-03
      • 1970-01-01
      • 2016-04-23
      相关资源
      最近更新 更多