|
|
|
@ -15,7 +15,7 @@ class BookSearch
|
|
|
|
private $query;
|
|
|
|
private $query;
|
|
|
|
private $queryParts = array();
|
|
|
|
private $queryParts = array();
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
public function __construct($edismax = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$options = array
|
|
|
|
$options = array
|
|
|
|
(
|
|
|
|
(
|
|
|
|
@ -27,10 +27,13 @@ class BookSearch
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
$this->client = new \SolrClient($options);
|
|
|
|
$this->client = new \SolrClient($options);
|
|
|
|
$this->query = new \SolrDisMaxQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// use the Extended DisMax Query parser
|
|
|
|
if($edismax) {
|
|
|
|
$this->query->useEDisMaxQueryParser();
|
|
|
|
$this->query = new \SolrDisMaxQuery();
|
|
|
|
|
|
|
|
$this->query->useEDisMaxQueryParser();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->query = new \SolrQuery();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// most options like search fields, sorting, etc are already set
|
|
|
|
// most options like search fields, sorting, etc are already set
|
|
|
|
// as default in the Solr config and thus should be set only on a
|
|
|
|
// as default in the Solr config and thus should be set only on a
|
|
|
|
@ -45,6 +48,11 @@ class BookSearch
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setHandler($handler)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->client->setServlet(\SolrClient::SEARCH_SERVLET_TYPE, $handler);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function addCompoundQuery(array $texts, $field, $operator)
|
|
|
|
public function addCompoundQuery(array $texts, $field, $operator)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(count($texts) > 0) {
|
|
|
|
if(count($texts) > 0) {
|
|
|
|
|