Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.155
diff -u -p -r1.1.2.6.2.155 apachesolr_search.module
--- apachesolr_search.module	22 Jul 2010 04:34:23 -0000	1.1.2.6.2.155
+++ apachesolr_search.module	9 Aug 2010 16:08:27 -0000
@@ -950,19 +950,43 @@ function apachesolr_search_form_search_f
           // Get the original query and replace words.
           $query = apachesolr_current_query();
 
-          foreach ($suggestions as $word => $value) {
-            $replacements[$word] = $value->suggestion[0];
+          // The name of the suggestion object is equal to the name of the part of the phrase being queried, so we need to find out what that is.
+          $suggest = array_keys($suggestions);
+          $suggest = $suggest[0];
+                
+          // The actual suggestions are an array within the object returned by SOLR.
+          // Allow more than one suggestion to be returned if spellcheck.count in SOLR is greater than 1.
+          $suggestions = ($suggestions[$suggest]->suggestion);
+
+          // Is one of the suggestions the phrase that was searched for?
+          $ar_search = array_search($query->get_query_basic(), $suggestions);
+          if ($ar_search) {
+            $unset($suggestions[$ar_search]);
           }
-          $new_keywords = strtr($query->get_query_basic(), $replacements);
+          
+          // Show only if suggestions are different to current query.
+          if (count($suggestions) > 0 ) {
+            foreach ($suggestions as $suggestion) {
+              if (is_object($suggestion)) {
+                // If $suggestion is an object, then spellcheck.extendedResults is configured in SOLR config.
+                $str_suggestion = (string) $suggestion->word;
+                // Extended results lets us know how many results there are for each suggestion, so lets display that.
+                $suggestion_count = $suggestion->freq;
+                $suggestion = $str_suggestion . ' (' . $suggestion_count . ' results)';
+                $new_keywords .= l($suggestion, $query->get_path($str_suggestion)) . ', ';
+              }
+              else {
+                // If $suggestion is not an object then it will be an array of strings.
+                $new_keywords .= l($suggestion, $query->get_path($suggestion)) . ', ';
+              }
+            }
 
-          // Show only if suggestion is different than current query.
-          if ($query->get_query_basic() != $new_keywords) {
             $form['basic']['suggestion'] = array(
               '#prefix' => '<div class="spelling-suggestions">',
               '#suffix' => '</div>',
               '#type' => 'item',
               '#title' => t('Did you mean'),
-              '#value' => l($new_keywords, $query->get_path($new_keywords)),
+              '#value' => $new_keywords,
             );
           }
         }
