1,分页
$page = 1;
$size = 10;
$es_search = [
"scroll"=>"1m",
"size"=>$size,
"index"=>"index_search",
"from"=>$page*$size,
"body"=>[]
];
$client = ClientBuilder::create()->build();
$es = $client->search($es_search);
$scroll_id = $es['_scroll_id'];
if($page == 1){
return $es['hits']['hits'];//首页
}
$i = 1;
while( $i < $page ){
$response = $client->scroll(['scroll_id'=>$scroll_id,'scroll'=>'1m']);
if(count($response['hits']['hits'])>0){
$scroll_id = $response['_scroll_id'];
}else{
break;
}
$i++;
}
return $response['hits']['hits'];