我用映射创建了一个新索引。其中存储了500 000个文档。
我想更改索引的映射,但是在弹性搜索中是不可能的。所以我用新的新映射创建了另一个索引,现在我正尝试将文档从旧索引复制到新索引。
我正在使用扫描和滚动类型从旧索引中检索文档并将其复制到新索引。复制需要花费更多时间,并且系统运行缓慢。
下面是我正在使用的代码。
$client= app('elastic_search');
$params = [
"search_type" => "scan", // use search_type=scan
"scroll" => "30s", // how long between scroll requests. should be small!
"size" => 500000, // how many results *per shard* you want back
"index" => "admin_logs422",
"body" => [
"query" => [
"match_all" => []
]
]
];
$docs = $client->search($params); // Execute the search
$scroll_id = $docs['_scroll_id'];
while (\true) {
// Execute a Scroll request
$response = $client->scroll([
"scroll_id" => $scroll_id, //...using …
Run Code Online (Sandbox Code Playgroud)