Index: contrib/apachesolr_og/apachesolr_og.install
===================================================================
RCS file: contrib/apachesolr_og/apachesolr_og.install
diff -N contrib/apachesolr_og/apachesolr_og.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ contrib/apachesolr_og/apachesolr_og.install	25 Apr 2009 00:06:26 -0000
@@ -0,0 +1,34 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_install().
+ */
+function apachesolr_og_install() {
+  $facet_missing = variable_get('apachesolr_facet_missing', array());
+  $facet_missing['apachesolr_og']['im_og_gid'] = 1;
+  variable_set('apachesolr_facet_missing', $facet_missing);
+}
+
+/**
+ * Implementation of hook_enable().
+ */
+function apachesolr_og_enable() {
+  drupal_set_message(t('All existing Organic Group nodes will be re-indexed'), 'warning');
+  db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE nid IN (SELECT nid FROM {og})", time());
+  db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE nid IN (SELECT nid FROM {og_ancestry})", time());
+}
+
+/**
+ * Re-index so as to use new missing field query.
+ */
+function apachesolr_og_update_6000() {
+  $ret = array();
+  apachesolr_clear_last_index();
+  $ret[] = array('success' => TRUE, 'query' => 'Called function apachesolr_clear_last_index(). All content will be re-indexed');
+  $facet_missing = variable_get('apachesolr_facet_missing', array());
+  $facet_missing['apachesolr_og'][_apachesolr_og_gid_key()] = 1;
+  variable_set('apachesolr_facet_missing', $facet_missing);
+  return $ret;
+}
+
Index: contrib/apachesolr_og/apachesolr_og.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/contrib/apachesolr_og/apachesolr_og.module,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 apachesolr_og.module
--- contrib/apachesolr_og/apachesolr_og.module	25 Mar 2009 01:56:01 -0000	1.1.2.1
+++ contrib/apachesolr_og/apachesolr_og.module	25 Apr 2009 00:06:27 -0000
@@ -16,15 +16,14 @@ function apachesolr_og_apachesolr_update
       $document->setMultiValue(_apachesolr_og_gid_key(), $gid);
     }
   }
-  else {
-    $document->setMultiValue(_apachesolr_og_gid_key(), 0);
-  }
 }
 
 /**
  * Implementation of hook_apachesolr_modify_query().
  */
 function apachesolr_og_apachesolr_modify_query(&$query, &$params, $caller) {
+  // Fetch the group ID in results - however, this is currently not used.
+  // May be useful for custom theming.
   if ($caller == 'apachesolr_search') {
     $params['fl'] .= ',' . _apachesolr_og_gid_key();
   }
@@ -98,7 +97,9 @@ function apachesolr_og_block($op = 'list
       // Add the blocks
       $blocks = array();
       foreach ($enabled_facets as $delta => $facet_field) {
-        $blocks[$delta] = $facets[$delta] + array('cache' => BLOCK_CACHE_PER_PAGE,);
+        if (isset($facets[$delta])) {
+          $blocks[$delta] = $facets[$delta] + array('cache' => BLOCK_CACHE_PER_PAGE,);
+        }
       }
       return $blocks;
 
@@ -129,13 +130,13 @@ function apachesolr_og_block($op = 'list
 /**
  * Callback function for the 'Filter by group' facet block.
  */
-function apachesolr_og_group_name($facet) {
-  if ($facet == 0) {
-    return t('No group');
+function apachesolr_og_group_name($facet, &$options) {
+  if (!is_numeric($facet)) {
+    $options['html'] = TRUE;
+    return theme('placeholder', t('No group'));
   }
 
-  $sql = 'SELECT title FROM {node} WHERE nid = %d';
-  return db_result(db_query($sql, $facet));
+  return db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $facet));
 }
 
 /**
@@ -154,6 +155,10 @@ function apachesolr_og_theme() {
  * Theme the breadcrumb.
  */
 function theme_apachesolr_breadcrumb_im_og_gid($group_id) {
-  return apachesolr_og_group_name($group_id);
+  if (!is_numeric($group_id)) {
+    return t('No group');
+  }
+
+  return db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $group_id));
 }
 
