Elasticsearch - 复制类型?

时间:2016-07-21 22:09:36

标签: elasticsearch logstash

我在Elasticsearch中创建了一个索引,其类型为t1,文档为doc1 - docN。有没有办法通过API调用创建一个新类型t2,其中包含与t1doc1 - docN)相同的文档?

1 个答案:

答案 0 :(得分:0)

没有神奇的API调用。您需要索引这些文档。我建议来自其中一位Elastic开发者的博文:http://david.pilato.fr/blog/2015/05/20/reindex-elasticsearch-with-logstash/

你需要围绕这些方面的东西:

input {
  elasticsearch {
    hosts => [ "localhost:9200" ]
    index => "test_index"
    size => 500
    scroll => "5m"
    docinfo => true
    query => '{"query":{"term":{"_type":{"value":"test_type_1"}}}}'
  }
}

filter {
  mutate {
    remove_field => [ "@timestamp", "@version" ]
  }
}

output {
  elasticsearch {
    host => "localhost"
    port => "9200"
    protocol => "http"
    index => "test_index"
    document_type => "test_type_2"
    document_id => "%{[@metadata][_id]}"
  }
}