ENHANCEMENT Custom query params support in SolrIndex->search()

This commit is contained in:
Ingo Schommer 2012-09-03 16:20:22 +02:00
parent 2a3e882d70
commit 65ce258578
1 changed files with 19 additions and 3 deletions

View File

@ -169,8 +169,16 @@ abstract class SolrIndex extends SearchIndex {
Solr::service(get_class($this))->commit(false, false, false);
}
public function search($query, $offset = -1, $limit = -1) {
$service = Solr::service(get_class($this));
/**
* @param SearchQuery $query
* @param integer $offset
* @param integer $limit
* @param Array $params Extra request parameters passed through to Solr
* @return ArrayData Map with the following keys:
* - 'Matches': ArrayList of the matched object instances
*/
public function search(SearchQuery $query, $offset = -1, $limit = -1, $params = array()) {
$service = $this->getService();
SearchVariant::with(count($query->classes) == 1 ? $query->classes[0]['class'] : null)->call('alterQuery', $query, $this);
@ -266,7 +274,15 @@ abstract class SolrIndex extends SearchIndex {
if ($limit == -1) $limit = $query->limit;
if ($limit == -1) $limit = SearchQuery::$default_page_size;
$res = $service->search($q ? implode(' ', $q) : '*:*', $offset, $limit, array('fq' => implode(' ', $fq)), Apache_Solr_Service::METHOD_POST);
$params = array_merge($params, array('fq' => implode(' ', $fq)));
$res = $service->search(
$q ? implode(' ', $q) : '*:*',
$offset,
$limit,
$params,
Apache_Solr_Service::METHOD_POST
);
$results = new ArrayList();