Skip to content
Snippets Groups Projects
Commit 580eeb0c authored by Demian Katz's avatar Demian Katz
Browse files

Moved Solr query processing from Connector to Backend.

parent 35481569
No related merge requests found
...@@ -169,8 +169,8 @@ class Backend implements BackendInterface, MoreLikeThis, RetrieveBatchInterface ...@@ -169,8 +169,8 @@ class Backend implements BackendInterface, MoreLikeThis, RetrieveBatchInterface
} }
} }
$response = $this->connector $params->mergeWith($this->getQueryBuilder()->build($query));
->search($query, $offset, $limit, $this->getQueryBuilder(), $params); $response = $this->connector->search($params, $offset, $limit);
$collection = $this->createRecordCollection($response); $collection = $this->createRecordCollection($response);
$this->injectSourceIdentifier($collection); $this->injectSourceIdentifier($collection);
...@@ -241,8 +241,13 @@ class Backend implements BackendInterface, MoreLikeThis, RetrieveBatchInterface ...@@ -241,8 +241,13 @@ class Backend implements BackendInterface, MoreLikeThis, RetrieveBatchInterface
while (count($ids) > 0) { while (count($ids) > 0) {
$currentPage = array_splice($ids, 0, $pageSize, array()); $currentPage = array_splice($ids, 0, $pageSize, array());
$currentPage = array_map($formatIds, $currentPage); $currentPage = array_map($formatIds, $currentPage);
$query = new Query('id:(' . implode(' OR ', $currentPage) . ')'); $params = new ParamBag(
$next = $this->search($query, 0, $pageSize); array('q' => 'id:(' . implode(' OR ', $currentPage) . ')')
);
$this->injectResponseWriter($params);
$next = $this->createRecordCollection(
$this->connector->search($params, 0, $pageSize)
);
if (!$results) { if (!$results) {
$results = $next; $results = $next;
} else { } else {
......
...@@ -207,23 +207,16 @@ class Connector ...@@ -207,23 +207,16 @@ class Connector
/** /**
* Execute a search. * Execute a search.
* *
* @param AbstractQuery $query Search query * @param ParamBag $params Parameters
* @param integer $offset Search offset * @param integer $offset Search offset
* @param integer $limit Search limit * @param integer $limit Search limit
* @param QueryBuilder $queryBuilder Query builder
* @param ParamBag $params Parameters
* *
* @return string * @return string
*/ */
public function search(AbstractQuery $query, $offset, $limit, public function search(ParamBag $params, $offset, $limit)
QueryBuilder $queryBuilder, ParamBag $params = null {
) {
$params = $params ?: new ParamBag();
$params->set('start', $offset); $params->set('start', $offset);
$params->set('rows', $limit); $params->set('rows', $limit);
$params->mergeWith($queryBuilder->build($query));
return $this->select($params); return $this->select($params);
} }
...@@ -231,7 +224,7 @@ class Connector ...@@ -231,7 +224,7 @@ class Connector
* Write to the SOLR index. * Write to the SOLR index.
* *
* @param AbstractDocument $document Document to write * @param AbstractDocument $document Document to write
* @param string $format Serialization forma, either `json' or `xml' * @param string $format Serialization format, either 'json' or 'xml'
* @param string $handler Update handler * @param string $handler Update handler
* @param ParamBag $params Update handler parameters * @param ParamBag $params Update handler parameters
* *
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment