diff -uP -r DRUPAL-6--1/apachesolr_autocomplete.info contrib/apachesolr_autocomplete/apachesolr_autocomplete.info
--- DRUPAL-6--1/apachesolr_autocomplete.info	1969-12-31 18:00:00.000000000 -0600
+++ contrib/apachesolr_autocomplete/apachesolr_autocomplete.info	2009-06-19 17:24:48.464886433 -0500
@@ -0,0 +1,7 @@
+; $Id$
+name = Apache Solr autocomplete
+description = Enables autocomplete on Apache Solr search boxes
+dependencies[] = apachesolr
+dependencies[] = apachesolr_search
+package = "Apache Solr"
+core = "6.x"
diff -uP -r DRUPAL-6--1/apachesolr_autocomplete.module contrib/apachesolr_autocomplete/apachesolr_autocomplete.module
--- DRUPAL-6--1/apachesolr_autocomplete.module	1969-12-31 18:00:00.000000000 -0600
+++ contrib/apachesolr_autocomplete/apachesolr_autocomplete.module	2009-06-19 17:13:14.794446315 -0500
@@ -0,0 +1,221 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ *   Alters search forms to suggest terms using Apache Solr.
+ */
+ 
+/**
+ * Implementation of hook_form_alter().
+ */
+
+function apachesolr_autocomplete_form_alter(&$form, $form_state, $form_id) {
+  if ($form_id == "search_form" && $form['module']['#value'] == 'apachesolr_search') {
+    $form['basic']['inline']['keys']['#autocomplete_path'] = 'apachesolr_autocomplete/autocomplete';
+    $form['basic']['inline']['keys']["#size"] = 60;
+  }
+  if ($form_id == 'search_block_form' || $form_id == 'search_theme_form') {
+    $form[$form_id]['#autocomplete_path'] = 'apachesolr_autocomplete/autocomplete';
+  }
+}
+
+/**
+ * Implementation of hook_menu().
+ */
+function apachesolr_autocomplete_menu() {
+  $items = array();
+
+  $items['apachesolr_autocomplete/autocomplete'] = array(
+    'title' => t('Apache Solr Autocomplete'),
+    'page callback' => 'apachesolr_autocomplete_callback',
+    'page arguments' => array(),
+    'access callback' => 'user_access',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  return $items;
+}
+
+/**
+ * Callback for url apachesolr_autocomplete/autocomplete
+ * @param query The user-entered query
+ */
+function apachesolr_autocomplete_callback($query = '') {
+  $suggestions = apachesolr_autocomplete_get_suggestions($query);
+  print drupal_json($suggestions);
+}
+
+function apachesolr_autocomplete_get_suggestions($query) {
+  $results = array();
+  $results = module_invoke_all('apachesolr_autocomplete_suggestions', $query);
+  if (!is_array($results)) {
+    return false;
+  }
+  return $results;
+}
+
+/**
+ * Implementation of hook_theme().
+ */
+function apachesolr_autocomplete_theme() {
+  return array(
+    'apachesolr_autocomplete_highlight' => array(
+      'file' => 'apachesolr_autocomplete.module',
+      'arguments' => array(
+        'keys' => NULL,
+        'suggestion' => NULL,
+        'count' => NULL,
+      ),
+    ),
+  );
+}
+
+function theme_apachesolr_autocomplete_highlight($keys, $suggestion, $count = 0) {
+  $html = '';
+  $html .= '<div style="display:inline;float:left"><strong>' . substr($suggestion, 0, strlen($keys)) . '</strong>' . substr($suggestion, strlen($keys)) . '</div>';
+  if ($count) {
+    $html .= "<div style='font-size:80%;color:#888;float:right'>$count results</div><br style=clear:both>";
+  }
+  return $html;
+}
+      
+
+/** 
+ * Implementation of hook_apachesolr_autocomplete_suggestions().
+ *
+ * @param $keys 
+ *   The user-entered query.
+ */
+function apachesolr_autocomplete_apachesolr_autocomplete_suggestions($keys) {
+  $results = array();
+  $results = array_merge($results, _apachesolr_autocomplete_suggest_word_completion($keys, 5));
+  $results = array_merge($results, _apachesolr_autocomplete_suggest_additional_term($keys, 5));
+  return $results;
+}
+  
+/**
+ * Helper function that suggests ways to complete partial words.
+ *
+ * For example, if $keys = "learn", this might return suggestions like: 
+ *    learn, learning, learner, learnability.
+ * The suggested terms are returned in order of frequency (most frequent first).
+ *
+ */
+function _apachesolr_autocomplete_suggest_word_completion($keys, $suggestions_to_return = 5) {
+  // Extract last word 
+  preg_match('/^(:?(.* |))([^ ]+)$/', $keys, $matches);
+  $first_part = $matches[2];
+  $last_part = $matches[3];
+  // Don't handle more than one word right now (creates false expectations)
+  #if ($first_part != "") {
+  #  return array();
+  #}
+  if ($last_part == "") {
+    return array();
+  }
+  
+  $query = apachesolr_drupal_query($first_part, '', '', '');
+  
+  // Set parameters for partial term query
+  $params = array(
+    'facet' => 'true',
+    'facet.field' => 'body',
+    'facet.prefix' => $last_part,
+    'facet.limit' => $suggestions_to_return,
+    'facet.mincount' => 1,
+    'start' => 0,
+    'rows' => 0,
+  );
+  
+  // Cache the built query. Since all the built queries go through
+  // this process, all the hook_invocations will happen later
+  apachesolr_current_query($query);
+
+  // This hook allows modules to modify the query and params objects.
+  apachesolr_modify_query($query, $params, 'apachesolr_autocomplete');
+  if (!$query) {
+    return array();
+  }
+  
+  // Try to contact Solr
+  try {
+    $solr = apachesolr_get_solr();
+  }
+  catch (Exception $e) {
+    watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR);
+    return array();
+  }
+  
+  // Query Solr
+  $response = $solr->search($first_part, $params['start'], $params['rows'], $params);
+  $suggestions = array();  
+  $matches = $response->facet_counts->facet_fields->body;
+  
+  // Build array of suggestions
+  foreach ($matches as $match => $count) {
+    if ($count > 0) {
+      $suggestion = $first_part . $match;
+      $suggestions[$suggestion] = theme('apachesolr_autocomplete_highlight', $keys, $suggestion, $count);
+    }
+  }
+  return $suggestions;
+}
+
+/**
+ * Helper function that suggests additional terms to search for.
+ *
+ * For example, if $keys = "learn", this might return suggestions like: 
+ *    learn student, learn school, learn mathematics.
+ * The suggested terms are returned in order of frequency (most frequent first).
+ *
+ */
+function _apachesolr_autocomplete_suggest_additional_term($keys, $suggestions_to_return = 5) {
+  $keys = trim($keys);
+  if ($keys == "") {
+    return array();
+  }
+  
+  $query = apachesolr_drupal_query($keys, '', '', '');
+  
+  // Set parameters for partial term query
+  $params = array(
+    'facet' => 'true',
+    'facet.field' => 'spell',
+    'facet.limit' => $suggestions_to_return,
+    'facet.mincount' => 1,
+    'start' => 0,
+    'rows' => 0,
+  );
+  
+  apachesolr_current_query($query);
+
+  // Allow other modules to modify query.
+  apachesolr_modify_query($query, $params, 'apachesolr_autocomplete');
+  if (!$query) {
+    return array();
+  }
+  
+  // Try to contact Solr.
+  try {
+    $solr = apachesolr_get_solr();
+  }
+  catch (Exception $e) {
+    watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR);
+    return array();
+  }
+  
+  // Query Solr
+  $response = $solr->search($keys, $params['start'], $params['rows'], $params);
+  $suggestions = array();  
+  $matches = $response->facet_counts->facet_fields->spell;
+  
+  // Build array of suggestions
+  foreach ($matches as $match => $count) {
+    if ($count > 0 && $keys != $match) {
+      $suggestion = $keys . ' ' . $match;
+      $suggestions[$suggestion] = theme('apachesolr_autocomplete_highlight', $keys, $suggestion, $count);
+    }
+  }
+  return $suggestions;
+}
