【发布时间】:2019-03-29 22:40:17
【问题描述】:
我需要尽快索引大约 1000 个文档。我决定使用比我原来的解决方案快 10 倍的批量功能。我需要在索引结束后立即创建refresh 以使文档可搜索。在其他情况下,我会使用刷新参数 'refresh' => true, 但我无法使其在 PHP 中批量处理。我用code from official documentation。
for($i = 0; $i < 100; $i++) {
$params['body'][] = [
'index' => [
'_index' => 'my_index',
'_type' => 'my_type',
]
];
$params['body'][] = [
'my_field' => 'my_value',
'second_field' => 'some more values'
];
}
$responses = $client->bulk($params);
在 PHP 批量函数中使用刷新的正确方法是什么?
【问题讨论】:
标签: php elasticsearch