activate search components on a per usage basis

master
Gilles Crettenand 11 years ago
parent 9790f4a456
commit 85c1c5d785

@ -137,10 +137,13 @@ class BookSearch
/**
* @param int $start
* @param int $count
* @param bool $facets activate faceting ?
* @param bool $spellcheck activate spellcheck ?
* @param bool $highlight activate highlighting ?
* @return array
* @throws WebException
*/
public function getResults($start = 0, $count = 15)
public function getResults($start = 0, $count = 15, $facets = false, $spellcheck = false, $highlight = false)
{
if (count($this->queryParts) == 0)
$query = '*:*';
@ -154,6 +157,11 @@ class BookSearch
$this->query->setStart($start);
$this->query->setRows($count);
$this->query->setParam('facet', $facets ? 'true' : 'false');
$this->query->setParam('hl', $highlight ? 'true' : 'false');
$this->query->setParam('spellcheck', $spellcheck ? 'true' : 'false');
try {
$results = $this->client->query($this->query)->getArrayResponse();
} catch(\SolrException $e) {
@ -227,9 +235,6 @@ class BookSearch
$this->query->setStart(0);
$this->query->setRows(0);
$this->query->setParam('suggest', 'true');
$this->query->setParam('facet', 'false');
$this->query->setParam('hl', 'false');
$this->query->setParam('spellcheck', 'false');
try {
$results = $this->client->query($this->query)->getArrayResponse();
@ -296,7 +301,7 @@ class BookSearch
$s->addFilterQuery(1, 'visible');
$s->addFacetField($field);
$s->setFacetLimits(2000, 10);
$results = $s->getResults(0, 0);
$results = $s->getResults(0, 0, true);
return $results['facets']['facets'][$field];
}
@ -309,7 +314,7 @@ class BookSearch
$s->setFacetRange(0, 250 * 60, 30);
// to avoid useless calculation, only set this 'normal' facet
$s->addFacetField('visible');
$results = $s->getResults(0, 0);
$results = $s->getResults(0, 0, true);
return $results['facets']['facets'][$field];
}

@ -13,7 +13,7 @@ use BSR\Lib\WebService;
class NetBiblio extends WebService
{
/** @var string $version version number */
public static $version = '1.1.2';
public static $version = '1.1.3';
private $login = '';
private $client = 'website';
@ -705,8 +705,11 @@ class NetBiblio extends WebService
$count = isset($queryArray['count']) ? (int) $queryArray['count'] : Configuration::get('solr.result_count');
$start = isset($queryArray['page']) ? $queryArray['page'] * $count : 0;
$facets = isset($queryArray['facets']) && $queryArray['facets'];
$spellcheck = isset($queryArray['spellcheck']) && $queryArray['spellcheck'];
$highlight = isset($queryArray['highlight']) && $queryArray['highlight'];
$results = $bs->getResults($start, $count);
$results = $bs->getResults($start, $count, $facets, $spellcheck, $highlight);
$data = array(
'count' => $results['count'],
'facets' => $results['facets'],

Loading…
Cancel
Save