
如果您愿意利用Logstash,则无需修改文件,而可以简单地逐行读取文件,并使用
elasticsearch利用Bulk API 的输出将其流式传输到ES
。
将以下Logstash配置存储在一个名为的文件中
es.conf(确保该文件
path和ES
hosts与您的设置匹配):
input { file { path => "/path/to/your/json" sincedb_path => "/dev/null" start_position => "beginning" prec => "json" }}filter { mutate { remove_fields => ["@version", "@timestamp"] }}output { elasticsearch { hosts => "localhost:9200" index => "test" document_type => "type1" document_id => "%{id}" }}然后,您需要安装logstash,并且将能够运行以下命令,以便将JSON文件加载到ES服务器:
bin/logstash -f es.conf
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)