MoreLikeThis API

This commit is contained in:
Gilles Crettenand
2015-06-18 14:19:12 +02:00
parent 5ebe300c28
commit 240ed85dbc
2 changed files with 45 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ class BookSearch
private $query;
private $queryParts = array();
public function __construct()
public function __construct($edismax = true)
{
$options = array
(
@@ -27,10 +27,13 @@ class BookSearch
);
$this->client = new \SolrClient($options);
$this->query = new \SolrDisMaxQuery();
// use the Extended DisMax Query parser
$this->query->useEDisMaxQueryParser();
if($edismax) {
$this->query = new \SolrDisMaxQuery();
$this->query->useEDisMaxQueryParser();
} else {
$this->query = new \SolrQuery();
}
// most options like search fields, sorting, etc are already set
// 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)
{
if(count($texts) > 0) {