Fix BookSearch
This commit is contained in:
@@ -3,14 +3,15 @@
|
|||||||
namespace BSR\Lib\Search;
|
namespace BSR\Lib\Search;
|
||||||
|
|
||||||
use BSR\Lib\Configuration;
|
use BSR\Lib\Configuration;
|
||||||
|
use BSR\Lib\Exception\WebException;
|
||||||
|
|
||||||
mb_http_output('UTF-8');
|
mb_http_output('UTF-8');
|
||||||
|
|
||||||
class BookSearch
|
class BookSearch
|
||||||
{
|
{
|
||||||
/** @var SolrClient */
|
/** @var \SolrClient */
|
||||||
private $client;
|
private $client;
|
||||||
/** @var SolrQuery */
|
/** @var \SolrQuery */
|
||||||
private $query;
|
private $query;
|
||||||
private $queryParts = array();
|
private $queryParts = array();
|
||||||
|
|
||||||
@@ -25,8 +26,8 @@ class BookSearch
|
|||||||
'path' => Configuration::get('solr.path'),
|
'path' => Configuration::get('solr.path'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->client = new SolrClient($options);
|
$this->client = new \SolrClient($options);
|
||||||
$this->query = new SolrQuery();
|
$this->query = new \SolrQuery();
|
||||||
$this->query->setQuery('*:*');
|
$this->query->setQuery('*:*');
|
||||||
|
|
||||||
$this->query->addField('*');
|
$this->query->addField('*');
|
||||||
@@ -37,7 +38,7 @@ class BookSearch
|
|||||||
public function addQuery($queryText, $queryField = null, $escape = true)
|
public function addQuery($queryText, $queryField = null, $escape = true)
|
||||||
{
|
{
|
||||||
if($escape) {
|
if($escape) {
|
||||||
$queryText = SolrUtils::escapeQueryChars($queryText);
|
$queryText = \SolrUtils::escapeQueryChars($queryText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($queryField) > 0) {
|
if (strlen($queryField) > 0) {
|
||||||
@@ -47,7 +48,7 @@ class BookSearch
|
|||||||
$this->queryParts[] = $queryText;
|
$this->queryParts[] = $queryText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSortField($field, $order = SolrQuery::ORDER_DESC)
|
public function addSortField($field, $order = \SolrQuery::ORDER_DESC)
|
||||||
{
|
{
|
||||||
$this->query->addSortField($field, $order);
|
$this->query->addSortField($field, $order);
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ class BookSearch
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$results = $this->client->query($this->query)->getResponse();
|
$results = $this->client->query($this->query)->getResponse();
|
||||||
} catch(SolrClientException $e) {
|
} catch(\SolrClientException $e) {
|
||||||
throw new WebException ("SolrError", $e->getMessage(), -700);
|
throw new WebException ("SolrError", $e->getMessage(), -700);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user