我在Elasticsearch中创建了一个索引,类型为t1
,文档为doc1
-docN
。是否有方法通过API调用创建一个新类型t2
,该类型包含与t1
(doc1
-docN
)相同的文档?
对此没有神奇的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]}"
}
}