zoukankan      html  css  js  c++  java
  • 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 号映射。

  • 相关阅读:
    linux 删除乱码文件
    snprintf用法
    面试时经常问到的非技术性问题
    vector查找元素
    new 和delete
    python安装
    UIPickerView详解
    设置文本框左边显示的View
    字符串的分割??
    VC++异常捕获??
  • 原文地址:https://www.cnblogs.com/monkeybron/p/10898271.html
Copyright © 2011-2022 走看看