[英]No effect of “size” in ‘query’ while reindexing in elasticsearch
我一直在使用logstash将索引迁移到另一个索引。 我最近尝试从本地环境中的大型数据集中重新索引一定数量的数据。 因此,我尝试使用以下配置进行迁移:
input{
elasticsearch{
hosts=>"localhost:9200"
index=>"old_indexindex"
query=>'{"query":{"match_all":{}},"size":10 }'
}
}filter{
mutate{
remove_field=>[
"@version",
"@timestamp"
]
}
}output{
elasticsearch{
hosts=>"localhost:9200"
index=>"new_index"
document_type=>"contact"
manage_template=>false
document_id=>"%{contactId}"
}
}
但这会将old_index中的所有文档重新索引为new_index ,其中,作为,我希望在new_index中仅将10个文档重新索引。 我是否在使用带弹性搜索的logstash时缺少某些概念?
elasticsearch
输入不进行常规搜索,而是执行扫描/滚动搜索类型。 这意味着,所有的数据都会从索引检索和作用size
的参数只是用来定义多少数据将在每次滚动过程中获取的,没有多少数据将被完全取出。
另外,请注意查询中的size
参数本身无效。 您需要使用elasticsearch
输入的size
参数 ,而不要在查询中指定它。
input{
elasticsearch{
hosts=> "localhost:9200"
index=> "old_index"
query=> '*'
size => 10 <--- size goes here
}
}
话虽如此,如果您运行的是ES 2.3或更高版本,则可以使用Reindex API来实现所需的目标,如下所示:
POST /_reindex
{
"size": 10,
"source": {
"index": "old_index"
},
"dest": {
"index": "new_index"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.