diff --git a/README.md b/README.md index aacdaa1..268b109 100644 --- a/README.md +++ b/README.md @@ -510,6 +510,27 @@ foreach($aggregateds as $key => $aggregated){ echo $aggregated['queries']; // how many "raw" search request. i.e.: "mp3", "mp3 p", "mp3 pl" .. echo $aggregated['requests']; // total number of requests for that day } + +$top_clicked = $mySearchEngine->top_terms('clicked', $from_date, $to_date); + +foreach($top_clicked as $key => $clicked){ + echo $clicked['term']; // title of the clicked item + echo $clicked['count']; // # of clicks on that item +} + +$top_searches = $mySearchEngine->top_terms('searches', $from_date, $to_date); + +foreach($top_searches as $key => $search){ + echo $search['term']; // search terms used + echo $search['count']; // # of times it's been used +} + +$top_opportunities = $mySearchEngine->top_terms('opportunities', $from_date, $to_date); + +foreach($top_opportunities as $key => $opportunity){ + echo $opportunity['term']; // search terms used (that haven't yielded any result) + echo $opportunity['count']; // # of times it's been used +} ```` ### Tasks management ### diff --git a/lib/doofinder_management_api.php b/lib/doofinder_management_api.php index a7cf266..24276a4 100644 --- a/lib/doofinder_management_api.php +++ b/lib/doofinder_management_api.php @@ -530,6 +530,10 @@ protected function fetchResultsAndTotal(){ "{$this->searchEngine->hashid}/stats/top_{$this->term}", array_merge($params, $this->searchParams) ); + // still generating? + if($apiResponse['statusCode'] == 202){ + throw new NotProcessedResponse("Your request is still being processed. Please try again later"); + } $this->resultsPage = $apiResponse['response'][$this->term]; $this->total = $apiResponse['response']['count']; $this->last_page++; diff --git a/lib/errors.php b/lib/errors.php index 875787c..1346eea 100644 --- a/lib/errors.php +++ b/lib/errors.php @@ -12,6 +12,8 @@ class WrongResponse extends Exception {} class ThrottledResponse extends Exception {} +class NotProcessedResponse extends Exception {} + function readError($response) { $error = json_decode($response, true); $error = $error['detail'];