如何使用php-elasticsearch客户端从elasticseach获取所有文档

时间:2018-07-31 09:29:46

标签: php elasticsearch

在我的索引之一中,我有80000个文档。我试图一次获得所有数据。上限为10000个数据。

如何通过php一次获取所有80000条记录?

我指的是此URL https://packagist.org/packages/elasticsearch/elasticsearch

$params = [
    "scroll" => "30s",          
    "size" => 10000,               
    "index" => $stdIndex,
    'type' => $stdIndexType];

$response = $client->search($params);

while (isset($response['hits']['hits']) && count($response['hits']['hits']) > 0) {
$scroll_id = $response['_scroll_id'];
$response = $client->scroll([
        "scroll_id" => $scroll_id,
        "scroll" => "30s"]
);
}

0 个答案:

没有答案