elasticsearch 当通过Logstash转储数据时,如何复制elasticsearch索引的_id和_类型
我有一个“索引”:带有“类型”的samcorp:“sam” 其中一个如下所示:elasticsearch 当通过Logstash转储数据时,如何复制elasticsearch索引的_id和_类型,elasticsearch,logstash,elasticsearch,Logstash,我有一个“索引”:带有“类型”的samcorp:“sam” 其中一个如下所示: { "_index": "samcorp", "_type": "sam", "_id": "1236", "_version": 1, "_score": 1, "_source": { "name": "Sam Smith", "age": 22, "confirmed": true, "join_date": "2014-06-01" } } 我想将
{
"_index": "samcorp",
"_type": "sam",
"_id": "1236",
"_version": 1,
"_score": 1,
"_source": {
"name": "Sam Smith",
"age": 22,
"confirmed": true,
"join_date": "2014-06-01"
}
}
我想将相同的数据复制到具有相同“类型”和相同“id”的不同“索引”名称“jamcorp”中
我正在使用Logstash来执行此操作:
我在logstash的配置文件中使用了下面的代码,结果是ID和类型错误
input {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "samcorp"
}
}
filter {
mutate {
remove_field => [ "@version", "@timestamp" ]
}
}
output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
manage_template => false
index => "jamcorp"
document_type => "%{_type}"
document_id => "%{_id}"
}
}
我已经尝试了所有可能的组合,我得到了以下输出:
输出:
{
"_index": "jamcorp",
"_type": "%{_type}",
"_id": "%{_id}",
"_version": 4,
"_score": 1,
"_source": {
"name": "Sam Smith",
"age": 22,
"confirmed": true,
"join_date": "2014-06-01"
}
}
我需要的是:
{
"_index": "jamcorp",
"_type": "sam",
"_id": "1236",
"_version": 4,
"_score": 1,
"_source": {
"name": "Sam Smith",
"age": 22,
"confirmed": true,
"join_date": "2014-06-01"
}
}
任何帮助都将不胜感激。:)感谢在您的
elasticsearch
输入中,您需要将设置为true
input {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "samcorp"
docinfo => true <--- add this
}
}
在
elasticsearch
输入中,需要将设置为true
input {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "samcorp"
docinfo => true <--- add this
}
}