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 號映射。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM