|
|
|
@ -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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|