I have this sample PHP code:
public function getListFromAzure($searchParam, $listCategory, $request){
$aListingManager = $this->get('recruitday.model_manager.job_listing');
$url = $jobListingManager->getAzureSearchParam($request, 'azure_search_idx');
$apiKey = $jobListingManager->getAzureSearchParam($request, 'azure_key');
$searchParam = preg_replace('/\s+/', '+', $searchParam);
$postdata = json_encode(
array(
'search' => $searchParam,
'filter' => $listCategory,
'orderby'=> 'publishedDate desc',
'facets' => array('locationName','empType', 'workSchedule','listFunction','positionLevel','industry'),
'top' => 15,
)
);
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/json
" .
"api-key: ". $apiKey . "
" .
"Accept: application/json",
'content'=>$postdata
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents($url, false, $context);
$file = json_decode($file,true);
return $file;
}
This works fine on a single query/page. Assuming I have 10,000 records to pull, and on a single query, azure search has limit of 1000 records. This should come up with azure search parameters $top- where it specifies how many items to return in a batch, and $skip specifies how many items to skip. inserted in this part of code:
$postdata = json_encode(
array(
'search' => $searchParam,
'filter' => $jobCategory,
'orderby'=> 'publishedDate desc',
'facets' => array('locationName','employmentType', 'workSchedule','jobFunction','positionLevel','industry'),
'top' => 15,
'skip' => 0,
'count' => true
)
);
assuming, this query will be for the 1st batch/page as top =15 records to be shown. for the next batch/page skip would iterate for example as 'skip' => 15.
The problem is I don't how to iterate this parameter. or should I iterate this? or there's another way?. azure search parameters reference: https://docs.microsoft.com/en-us/azure/search/search-pagination-page-layout
I'm thinking of appending json file. relevant search: Append data to a .JSON file with PHP
previously, I am having 1000 records shown. but I need to adjust since my records has more than 1000 records already. on the front end side -- I am calling this through ajax. then formed into html. then there I adjust the pagination through jquery/javascript turning into chunks of 20 records for (example) per page.
hope I don't confuse anyone. thank you in advance! cheers!
btw: I am using PHP, Symfony 2.