diff --git a/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php b/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php index 150b91a96b5e7bd6370c11b5a2f006c3662880ea..163af6f520bb7935cf5679d5ba50cdbf97c5d241 100644 --- a/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php +++ b/module/VuFind/src/VuFind/Search/Solr/MultiIndexListener.php @@ -116,9 +116,10 @@ class MultiIndexListener $backend = $event->getTarget(); if ($backend === $this->backend) { $params = $event->getParam('params'); - if ($event->getParam('context') == 'retrieve') { - // If we're retrieving a record, we should pull all shards to be - // sure we find it. + $allShardsContexts = ['retrieve', 'retrieveBatch']; + if (in_array($event->getParam('context'), $allShardsContexts)) { + // If we're retrieving by id(s), we should pull all shards to be + // sure we find the right record(s). $params->set('shards', implode(',', $this->shards)); } else { // In any other context, we should make sure our field values are diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php index 33025bc09cc17fd9b3b5363f89c0b815b842ac0c..555c0a4aa3e28189c85ff5757f662ea3d9348074 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Backend.php @@ -163,6 +163,8 @@ class Backend extends AbstractBackend */ public function retrieveBatch($ids, ParamBag $params = null) { + $params = $params ?: new ParamBag(); + // Load 100 records at a time; this is a good number to avoid memory // problems while still covering a lot of ground. $pageSize = 100; @@ -177,13 +179,9 @@ class Backend extends AbstractBackend while (count($ids) > 0) { $currentPage = array_splice($ids, 0, $pageSize, []); $currentPage = array_map($formatIds, $currentPage); - $params = new ParamBag( - [ - 'q' => 'id:(' . implode(' OR ', $currentPage) . ')', - 'start' => 0, - 'rows' => $pageSize - ] - ); + $params->set('q', 'id:(' . implode(' OR ', $currentPage) . ')'); + $params->set('start', 0); + $params->set('rows', $pageSize); $this->injectResponseWriter($params); $next = $this->createRecordCollection( $this->connector->search($params)