logstash系列一使用logstash迁移ES数据

es的文档id生成方式可以是 自动的uuid,也可以是自定义的id,可以用业务中的id字段进行映射

自动的id,URL安全,base64编码,GUID,如下:


POST /test_index/test_type 
{ "test_content": "my test" }

手动的就靠自己定义

PUT /test_index/test_type/2
{
  "test_content": "my test"
}

那么使用logstash抽取数据是怎么做映射的?配置文件如下:

input {
    elasticsearch {
        hosts => ["192.168.0.1:9200"]
        index => "ddd"
        query => '{ "query": {"match_all" : {} } }'
        size => 1000
        scroll => "1m"
        codec => "json"
        docinfo => true
    }
}

output {
    stdout {
      codec => rubydebug
    }
    elasticsearch {
        hosts => ["192.168.0.2:9200"]
        document_type => "messages"
        document_id => "%{id}" 
        index => "ddd"
    }
}
 document_id => "%{id}"  指定 文档id 使用自己定义json 文件中的id 号映射。

原文地址:https://www.cnblogs.com/monkeybron/p/10898271.html