diff --git a/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php b/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php
index fe2fb07527ebc38f4e496095507ea9deebd9abeb..cff0a1353dca2bcb340eeb68abdadb5a07bed637 100644
--- a/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php
+++ b/module/VuFind/src/VuFind/Search/Solr/InjectSpellingListener.php
@@ -160,9 +160,11 @@ class InjectSpellingListener
             $result = $event->getTarget();
             $params = $event->getParam('params');
             $spellcheckQuery = $params->get('spellcheck.q');
-            $this->aggregateSpellcheck(
-                $result->getSpellcheck(), end($spellcheckQuery)
-            );
+            if (!empty($spellcheckQuery)) {
+                $this->aggregateSpellcheck(
+                    $result->getSpellcheck(), end($spellcheckQuery)
+                );
+            }
         }
     }
 
diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php
index 756e3d8e4805a5f320ae9c44c19fedac70c1e408..d9158d8623420d16d79c968b13bb44d5eaea8777 100644
--- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php
+++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php
@@ -98,11 +98,13 @@ class RecordCollection extends AbstractRecordCollection
     public function getSpellcheck()
     {
         if (!$this->spellcheck) {
-            $sq = isset($this->response['responseHeader']['params']['spellcheck.q'])
-                ? $this->response['responseHeader']['params']['spellcheck.q']
-                : $this->response['responseHeader']['params']['q'];
-            $this->spellcheck
-                = new Spellcheck($this->response['spellcheck']['suggestions'], $sq);
+            $params = isset($this->response['responseHeader']['params'])
+                ? $this->response['responseHeader']['params'] : array();
+            $sq = isset($params['spellcheck.q'])
+                ? $params['spellcheck.q'] : $params['q'];
+            $sugg = isset($this->response['spellcheck']['suggestions'])
+                ? $this->response['spellcheck']['suggestions'] : array();
+            $this->spellcheck = new Spellcheck($sugg, $sq);
         }
         return $this->spellcheck;
     }