activate search components on a per usage basis
This commit is contained in:
@@ -137,10 +137,13 @@ class BookSearch
|
|||||||
/**
|
/**
|
||||||
* @param int $start
|
* @param int $start
|
||||||
* @param int $count
|
* @param int $count
|
||||||
|
* @param bool $facets activate faceting ?
|
||||||
|
* @param bool $spellcheck activate spellcheck ?
|
||||||
|
* @param bool $highlight activate highlighting ?
|
||||||
* @return array
|
* @return array
|
||||||
* @throws WebException
|
* @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)
|
if (count($this->queryParts) == 0)
|
||||||
$query = '*:*';
|
$query = '*:*';
|
||||||
@@ -154,6 +157,11 @@ class BookSearch
|
|||||||
$this->query->setStart($start);
|
$this->query->setStart($start);
|
||||||
$this->query->setRows($count);
|
$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 {
|
try {
|
||||||
$results = $this->client->query($this->query)->getArrayResponse();
|
$results = $this->client->query($this->query)->getArrayResponse();
|
||||||
} catch(\SolrException $e) {
|
} catch(\SolrException $e) {
|
||||||
@@ -227,9 +235,6 @@ class BookSearch
|
|||||||
$this->query->setStart(0);
|
$this->query->setStart(0);
|
||||||
$this->query->setRows(0);
|
$this->query->setRows(0);
|
||||||
$this->query->setParam('suggest', 'true');
|
$this->query->setParam('suggest', 'true');
|
||||||
$this->query->setParam('facet', 'false');
|
|
||||||
$this->query->setParam('hl', 'false');
|
|
||||||
$this->query->setParam('spellcheck', 'false');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$results = $this->client->query($this->query)->getArrayResponse();
|
$results = $this->client->query($this->query)->getArrayResponse();
|
||||||
@@ -296,7 +301,7 @@ class BookSearch
|
|||||||
$s->addFilterQuery(1, 'visible');
|
$s->addFilterQuery(1, 'visible');
|
||||||
$s->addFacetField($field);
|
$s->addFacetField($field);
|
||||||
$s->setFacetLimits(2000, 10);
|
$s->setFacetLimits(2000, 10);
|
||||||
$results = $s->getResults(0, 0);
|
$results = $s->getResults(0, 0, true);
|
||||||
|
|
||||||
return $results['facets']['facets'][$field];
|
return $results['facets']['facets'][$field];
|
||||||
}
|
}
|
||||||
@@ -309,7 +314,7 @@ class BookSearch
|
|||||||
$s->setFacetRange(0, 250 * 60, 30);
|
$s->setFacetRange(0, 250 * 60, 30);
|
||||||
// to avoid useless calculation, only set this 'normal' facet
|
// to avoid useless calculation, only set this 'normal' facet
|
||||||
$s->addFacetField('visible');
|
$s->addFacetField('visible');
|
||||||
$results = $s->getResults(0, 0);
|
$results = $s->getResults(0, 0, true);
|
||||||
|
|
||||||
return $results['facets']['facets'][$field];
|
return $results['facets']['facets'][$field];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use BSR\Lib\WebService;
|
|||||||
class NetBiblio extends WebService
|
class NetBiblio extends WebService
|
||||||
{
|
{
|
||||||
/** @var string $version version number */
|
/** @var string $version version number */
|
||||||
public static $version = '1.1.2';
|
public static $version = '1.1.3';
|
||||||
|
|
||||||
private $login = '';
|
private $login = '';
|
||||||
private $client = 'website';
|
private $client = 'website';
|
||||||
@@ -705,8 +705,11 @@ class NetBiblio extends WebService
|
|||||||
|
|
||||||
$count = isset($queryArray['count']) ? (int) $queryArray['count'] : Configuration::get('solr.result_count');
|
$count = isset($queryArray['count']) ? (int) $queryArray['count'] : Configuration::get('solr.result_count');
|
||||||
$start = isset($queryArray['page']) ? $queryArray['page'] * $count : 0;
|
$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(
|
$data = array(
|
||||||
'count' => $results['count'],
|
'count' => $results['count'],
|
||||||
'facets' => $results['facets'],
|
'facets' => $results['facets'],
|
||||||
|
|||||||
Reference in New Issue
Block a user