Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 如何使用Logstash或curl向ElasticSearch提供数据?_Json_Curl_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Logstash - Fatal编程技术网 elasticsearch,logstash,Json,Curl,elasticsearch,Logstash" /> elasticsearch,logstash,Json,Curl,elasticsearch,Logstash" />

Json 如何使用Logstash或curl向ElasticSearch提供数据?

Json 如何使用Logstash或curl向ElasticSearch提供数据?,json,curl,elasticsearch,logstash,Json,Curl,elasticsearch,Logstash,我正在尝试将所有json导入elasticsearch。为此,我尝试了curl命令,但没有用,因为它开始出现解析错误。 这就是我所尝试的: curl -XPOST "http://localhost:9200/test" -d "@test.json" curl -XPOST "http://localhost:9200/test/_bulk" -d "@test.json" curl -XPOST "http://localhost:9200/test/_bulk" --data-binary

我正在尝试将所有json导入elasticsearch。为此,我尝试了
curl
命令,但没有用,因为它开始出现解析错误。
这就是我所尝试的:

curl -XPOST "http://localhost:9200/test" -d "@test.json"
curl -XPOST "http://localhost:9200/test/_bulk" -d "@test.json"
curl -XPOST "http://localhost:9200/test/_bulk" --data-binary "@test.json"
curl -s -XPOST "http://localhost:9200/test/_bulk" --data-binary "@test.json"
还有许多其他的尝试。但我得到的是
解析错误
。因此,我想知道向elasticsearch提供我所有记录的方法是什么?
此外,如果有人能帮我解决它与logstash然后它将是一个伟大的帮助。请告诉我最好的建议。
这是JSON中的示例数据,可能用换行符分隔
以下是错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "parse_exception",
        "reason" : "Failed to derive xcontent"
      }
    ],
    "type" : "parse_exception",
    "reason" : "Failed to derive xcontent"
  },
  "status" : 400
}

您需要像这样更改json:

{ "index" : { "_index" : "test", "_type" : "type" } }
{"data":...}
{ "index" : { "_index" : "test", "_type" : "type" } }
{"data":...}
{ "index" : { "_index" : "test", "_type" : "type" } }
{"data":...}
然后您可以运行:

curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@test.json"
阅读更多关于

如果您希望使用Logstash实现这一点,可以使用a和a,然后使用。类似(未经测试):

然后启动:

cat test.json | bin/logstash -f logstash.conf

我希望这有帮助。

您需要像这样更改json:

{ "index" : { "_index" : "test", "_type" : "type" } }
{"data":...}
{ "index" : { "_index" : "test", "_type" : "type" } }
{"data":...}
{ "index" : { "_index" : "test", "_type" : "type" } }
{"data":...}
然后您可以运行:

curl -s -H "Content-Type: application/x-ndjson" -XPOST localhost:9200/_bulk --data-binary "@test.json"
阅读更多关于

如果您希望使用Logstash实现这一点,可以使用a和a,然后使用。类似(未经测试):

然后启动:

cat test.json | bin/logstash -f logstash.conf

我希望这会有所帮助。

BTW如果您将文件拆分为多个文件,如每个文件一个JSON文档,则可以使用project。Let-us.BTW如果您将文件拆分为多个文件,如每个文件一个JSON文档,则可以使用project.Let-us。