work on search: doc, bug fix, factorisation
This commit is contained in:
@@ -35,6 +35,15 @@ class BookSearch
|
||||
$this->query->addParam('q.op', 'AND');
|
||||
}
|
||||
|
||||
public function addOrQuery(array $texts, $field)
|
||||
{
|
||||
if(count($texts) > 0) {
|
||||
$texts = array_map(array('SolrUtils', 'escapeQueryChars'), $texts);
|
||||
$query = sprintf('%s:(%s)', $field, implode(' OR ', $texts));
|
||||
$this->addQuery($query, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
public function addQuery($queryText, $queryField = null, $escape = true)
|
||||
{
|
||||
if($escape) {
|
||||
@@ -115,8 +124,7 @@ class BookSearch
|
||||
}
|
||||
|
||||
$bs = new static();
|
||||
$query = sprintf('%s:(%s)', $field, implode(' OR ', $codes));
|
||||
$bs->addQuery($query, null, false);
|
||||
$bs->addOrQuery($codes, $field);
|
||||
$results = $bs->getResults(0, $count);
|
||||
return $results['books'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user