diff --git a/src/Plugin/search_api/backend/SearchApiSolrBackend.php b/src/Plugin/search_api/backend/SearchApiSolrBackend.php
index 4916171..6d84c27 100644
--- a/src/Plugin/search_api/backend/SearchApiSolrBackend.php
+++ b/src/Plugin/search_api/backend/SearchApiSolrBackend.php
@@ -46,6 +46,7 @@ use Solarium\QueryType\Suggester\Query as SuggesterQuery;
 use Solarium\QueryType\Suggester\Result\Result as SuggesterResult;
 use Solarium\QueryType\Update\Query\Document\Document;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\search_api\Item\Field;
 
 /**
  * The minimum required Solr schema version.
@@ -1342,20 +1343,23 @@ class SearchApiSolrBackend extends BackendPluginBase implements SolrBackendInter
     // If field collapsing has been enabled for this query, we need to process
     // the results differently.
     $grouping = $query->getOption('search_api_grouping');
-    $docs = array();
     if (!empty($grouping['use_grouping']) && $is_grouping) {
-//      $docs = array();
-//      $result_set['result count'] = 0;
-//      foreach ($grouping['fields'] as $field) {
-//        if (!empty($response->grouped->{$fields[$field]})) {
-//          $result_set['result count'] += $response->grouped->{$fields[$field]}->ngroups;
-//          foreach ($response->grouped->{$fields[$field]}->groups as $group) {
-//            foreach ($group->doclist->docs as $doc) {
-//              $docs[] = $doc;
-//            }
-//          }
-//        }
-//      }
+      $docs = array();
+      $resultCount = 0;
+      if($result_set->hasExtraData("search_api_solr_response")) {
+        $response = $result_set->getExtraData("search_api_solr_response");
+        foreach ($grouping['fields'] as $field) {
+          if (!empty($response["grouped"][$field_names[$field]])) {
+            $resultCount += $response["grouped"][$field_names[$field]]["ngroups"];
+            foreach ($response["grouped"][$field_names[$field]]["groups"] as $group) {
+              foreach ($group["doclist"]["docs"] as $doc) {
+                $docs[] = $doc;
+              }
+            }
+          }
+        }
+      }
+      $result_set->setResultCount($resultCount);
     }
     else {
       $result_set->setResultCount($result->getNumFound());
@@ -1365,7 +1369,12 @@ class SearchApiSolrBackend extends BackendPluginBase implements SolrBackendInter
     // Add each search result to the results array.
     /** @var \Solarium\QueryType\Select\Result\Document $doc */
     foreach ($docs as $doc) {
-      $doc_fields = $doc->getFields();
+      if(is_array($doc)) {
+        $doc_fields = $doc;
+      } else {
+        $doc_fields = $doc->getFields();
+      }
+
       $item_id = $doc_fields[$id_field];
       // For items coming from a different site, we need to adapt the item ID.
       if (!$this->configuration['site_hash'] && $doc_fields['hash'] != $site_hash) {
@@ -2448,6 +2457,7 @@ class SearchApiSolrBackend extends BackendPluginBase implements SolrBackendInter
    * @todo This code is outdated and needs to be reviewd and refactored.
    */
   protected function setGrouping(Query $solarium_query, QueryInterface $query, $grouping_options = array(), $index_fields = array(), $field_names = array()) {
+    $solarium_query->getGrouping();
     $group_params['group'] = 'true';
     // We always want the number of groups returned so that we get pagers done
     // right.
@@ -2459,7 +2469,9 @@ class SearchApiSolrBackend extends BackendPluginBase implements SolrBackendInter
       $group_params['group.facet'] = 'true';
     }
     foreach ($grouping_options['fields'] as $collapse_field) {
-      $type = $index_fields[$collapse_field]['type'];
+      /** @var $field Field $type */
+      $field = $index_fields[$collapse_field];
+      $type = $field->getType();
       // Only single-valued fields are supported.
       if (SearchApiUtility::isTextType($type)) {
         $warnings[] = $this->t('Grouping is not supported for field @field. Only single-valued fields not indexed as "Fulltext" are supported.',
@@ -2474,8 +2486,8 @@ class SearchApiSolrBackend extends BackendPluginBase implements SolrBackendInter
     else {
       if (!empty($grouping_options['group_sort'])) {
         foreach ($grouping_options['group_sort'] as $group_sort_field => $order) {
-          if (isset($fields[$group_sort_field])) {
-            $f = $fields[$group_sort_field];
+          if (isset($field_names[$group_sort_field])) {
+            $f = $field_names[$group_sort_field];
             if (substr($f, 0, 3) == 'ss_') {
               $f = 'sort_' . substr($f, 3);
             }
