--- apachesolr_search-justfacets.module	2009-05-26 09:18:35.944644962 -0500
+++ apachesolr_search.module	2009-05-26 16:03:56.180700068 -0500
@@ -134,12 +134,75 @@
     else {
       $results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg()));
     }
+  } else {
+    // Show search form and browse-by blocks
+    $browse_by = apachesolr_search_browse();
+    return drupal_get_form('search_form', NULL, $keys, $type) . $browse_by;
   }
   // Construct the search form.
   return drupal_get_form('search_form', NULL, $keys, $type) . $results;
 }
 
 /**
+ * Execute an empty search (match all documents) and show a listing of all enabled facets.
+ */
+function apachesolr_search_browse() {
+  $query = apachesolr_drupal_query('', '', '', 'search/' . arg(1));
+  $params = array(
+    'start' => 0,
+    'rows' => 0,
+    'facet' => 'true',
+    'facet.mincount' => 1,
+    'facet.sort' => 'true'
+  );
+  
+  apachesolr_search_add_facet_params($params, $query);
+  
+  // This is the object that does the communication with the solr server.
+  $solr = apachesolr_get_solr();
+  
+  // Cache the built query. Since all the built queries go through
+  // this process, all the hook_invocations will happen later
+  apachesolr_current_query($query);
+  $response = $solr->search($query->get_query_basic(), $params['start'], $params['rows'], $params);
+  apachesolr_static_response_cache($response);
+  apachesolr_has_searched(TRUE);
+  $result = "";
+  
+  // Get blocks for all enabled filters
+  foreach (apachesolr_get_enabled_facets() as $module => $module_facets) {
+    foreach($module_facets as $delta => $facet_field) {
+      if ($delta == "currentsearch") {
+        continue;
+      }
+      $blocks[$facet_field] = (object)module_invoke($module, 'block', 'view', $delta);
+    }
+  }
+  
+  $result = theme('apachesolr_browse_blocks', $blocks);
+  
+  apachesolr_has_searched(FALSE);
+  
+  return $result;
+}
+
+/**
+ * Theming function that shows a groups of blocks so users can start a search from a filter.
+ *
+ * @param $blocks an array of block objects.
+ */
+function theme_apachesolr_browse_blocks($blocks) {
+  $result = "<div class='apachesolr_browse_block'><h2>" . t('Browse available categories') .'</h2>';
+  $result .= '<p>' . t('Pick a category to launch a search.') . '</p>';
+  foreach ($blocks as $facet_field => $block) {
+     $result .= theme('block', $block);
+  }
+  $result .= '</div>';
+
+  return $result;
+}
+
+/**
  * Execute a search results based on keyword, filter, and sort strings.
  *
  * @throws Exception
@@ -762,6 +825,9 @@
     'apachesolr_breadcrumb_created' => array(
       'arguments' => array('type' => NULL),
     ),
+    'apachesolr_browse_blocks' => array(
+      'arguments' => array('blocks' => NULL),
+    ),
     'apachesolr_currentsearch' => array(
       'arguments' => array('total_found' => NULL, 'links' => NULL),
     ),
