factorize solr results formatting in BookSearch
This commit is contained in:
@@ -357,12 +357,7 @@ class NetBiblio extends WebService
|
||||
$bs = new BookSearch();
|
||||
$bs->addSortField('random_'.$seed);
|
||||
$results = $bs->getResults(0, $number);
|
||||
|
||||
if($results['response']['docs']) {
|
||||
$books = array_map(function($o) { return (array) $o; }, $results['response']['docs']);
|
||||
return $this->AddBookData($books);
|
||||
}
|
||||
return array();
|
||||
return $results['books'] ? $this->AddBookData($results['books']) : array();
|
||||
}
|
||||
|
||||
public function Search($query, $start, $limit)
|
||||
@@ -444,21 +439,14 @@ class NetBiblio extends WebService
|
||||
$count = isset($queryArray['count']) ? (int) $queryArray['count'] : Configuration::get('solr.result_count');
|
||||
$start = isset($queryArray['page']) ? $queryArray['page'] * $count : 0;
|
||||
|
||||
try {
|
||||
$results = $bs->getResults($start, $count);
|
||||
} catch(SolrClientException $e) {
|
||||
throw new WebException ("SolrError", $e->getMessage(), -700);
|
||||
}
|
||||
|
||||
$results = $bs->getResults($start, $count);
|
||||
$data = array(
|
||||
'count' => $results['response']['numFound'],
|
||||
'facets' => $results['facet_counts']['facet_fields'],
|
||||
'count' => $results['count'],
|
||||
'facets' => $results['facets'],
|
||||
);
|
||||
|
||||
if($results['response']['docs']) {
|
||||
$books = array_map(function($o) { return (array) $o; }, $results['response']['docs']);
|
||||
$books = $this->AddBookData($books);
|
||||
$data = array_merge($data, $books);
|
||||
if($results['books']) {
|
||||
$data = array_merge($data, $this->AddBookData($results['books']));
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
Reference in New Issue
Block a user