java - 无法将 csv 数据加载到 Elasticsearch,翻译问题

标签 java ruby csv elasticsearch logstash

我尝试将 CSV 文件导入弹性文件,但失败并引发错误

Pipeline aborted due to error {:pipeline_id=>"main", :exception=>#, :backtrace=>["/usr/local/Cellar/logstash/7.6.1/libexec/vendor/bundle/jruby/2.5.0/gems/logstash-filter-mutate-3.5.0/lib/logstash/filters/mutate.rb:222:in block in register'", "org/jruby/RubyHash.java:1428:ineach'", "/usr/local/Cellar/logstash/7.6.1/libexec/vendor/bundle/jruby/2.5.0/gems/logstash-filter-mutate-3.5.0/lib/logstash/filters/mutate.rb:220:in register'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:56:in register'", "/usr/local/Cellar/logstash/7.6.1/libexec/logstash-core/lib/logstash/java_pipeline.rb:200:in block in register_plugins'", "org/jruby/RubyArray.java:1814:in each'", "/usr/local/Cellar/logstash/7.6.1/libexec/logstash-core/lib/logstash/java_pipeline.rb:199:in register_plugins'", "/usr/local/Cellar/logstash/7.6.1/libexec/logstash-core/lib/logstash/java_pipeline.rb:502:in maybe_setup_out_plugins'", "/usr/local/Cellar/logstash/7.6.1/libexec/logstash-core/lib/logstash/java_pipeline.rb:212:in start_workers'", "/usr/local/Cellar/logstash/7.6.1/libexec/logstash-core/lib/logstash/java_pipeline.rb:154:in run'", "/usr/local/Cellar/logstash/7.6.1/libexec/logstash-core/lib/logstash/java_pipeline.rb:109:in `block in start'"], "pipeline.sources"=>["/Users/user/Document/Esk-Data/xudaxia.conf"], :thread=>"#"}

下面是conf文件

input
{
    file{
    path => ["/test.csv"]
    start_position => "beginning"
    }
}
filter{
    csv{
        separator => ","
         columns => ["comment_time","comment", "id", "video_time"]
       }
    mutate{
        convert => {
            "comment_time" => "date_time"
            "comment" => "string"
            "id" => "integer"
            "video_time" => "float"
      }
    }
}
output{
    elasticsearch{
        hosts => ["localhost:9200"]
        index => "test"
    }
}

测试.csv

comment_time         comment        id        video_time
2020/03/22 15:59:41  バイ             a        123.100
2020/03/22 15:59:45  บาย             b        100.100
2020/04/22 15:59:50  ByeBye          c        80.210

有人可以帮忙吗?

最佳答案

根据文档,date_time 选项对于 mutate 插件的转换操作不存在 - doc here 。 然而,这个插件用于将一种类型转换为另一种类型,这不是您的用例。如果 comment_time 未被识别为日期字段,您应该使用 date 插件对其进行转换 - doc here .

所以你应该删除这个 block :

mutate{
    convert => {
        "comment_time" => "date_time"
        "comment" => "string"
        "id" => "integer"
        "video_time" => "float"
  }
}

并将其替换为以下内容:

date {
    match => [ "comment_time", "yyyy/MM/dd HH:mm:ss"
}

关于java - 无法将 csv 数据加载到 Elasticsearch,翻译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60902622/

相关文章:

ruby-on-rails - Rails 3.1 中的并行处理? -- 检查断开的链接

ruby - 如何在 Ruby 中进行高级字符串比较?

java - 计算直线与 x 轴之间的角度

java - Jacoco 显示 0% 覆盖率,即使在使用 @PrepareForTest 注释时成功执行测试用例

Java 套接字 : can I write a TCP server with one thread?

ruby - 如何使 Dir[] 和 Dir.foreach 以确定的顺序返回结果?

java - 如何在java中循环解析已解析的字符串

python - Pandas read_csv 导入结果出错

python - python读取utf-8 csv中文文件的方法

php - 使用导入上传 CSV 文件时,仅导入 1 条记录