? apachesolr_clear_index_button.5.x_0.patch ? apachesolr_clear_index_button.6.x.patch ? spellcheck.patch ? spellcheck_patch_230380_2.txt Index: apachesolr_search.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v retrieving revision 1.1.2.15 diff -u -p -w -r1.1.2.15 apachesolr_search.module --- apachesolr_search.module 4 Sep 2008 22:11:03 -0000 1.1.2.15 +++ apachesolr_search.module 9 Sep 2008 11:29:05 -0000 @@ -112,6 +112,28 @@ function apachesolr_search_search($op = $function = $module .'_apachesolr_process_results'; call_user_func_array($function, array(&$results)); } + } else { + // No results + // Try to show spelling suggestions + $host = variable_get('apachesolr_host', 'localhost'); + $port = variable_get('apachesolr_port', 8983); + $path = variable_get('apachesolr_path', '/solr'); + $request = "http://{$host}:{$port}{$path}/select?qt=spellchecker&q=". rawurlencode(check_plain($keys)); + $result = drupal_http_request($request); + if (preg_match_all('/(.*?)<\/str>/', $result->data, $matches)) { + $suggestions = $matches[1]; + foreach($suggestions as $s) { + $results[] = array('link' => url('search/apachesolr_search/'. $s, NULL, NULL, TRUE), + 'type' => NULL, + 'title' => t("No results. Did you mean '@suggestion'?", array('@suggestion' => $s)), + 'user' => NULL, + 'date' => NULL, + 'node' => NULL, + 'score' => 0, + 'snippet' => t('Your search yielded no results'). search_help('search#noresults')); + break; + } + } } // Set breadcrumb drupal_set_breadcrumb($query->get_breadcrumb()); @@ -125,3 +147,24 @@ function apachesolr_search_search($op = } // switch } + +/* + * Implementation of hook_cron() + */ +function apachesolr_search_cron() { + // Rebuild spelling dictionary every 24 hours + $last = variable_get('apachesolr_search_spellrebuildtime', 0); + if ($_SERVER['REQUEST_TIME'] < $last + 3600 * 24) { + return; + } + $host = variable_get('apachesolr_host', 'localhost'); + $port = variable_get('apachesolr_port', 8983); + $path = variable_get('apachesolr_path', '/solr'); + + // http://example.com:8983/solr/select?qt=spellchecker&cmd=rebuild + $request = "http://{$host}:{$port}{$path}/solr/select?qt=spellchecker&cmd=rebuild"; + $result = drupal_http_request($request); + + // Mark time of last spellchecker rebuild + variable_set('apachesolr_search_spellrebuildtime', $_SERVER['REQUEST_TIME']); +} Index: schema.xml =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/schema.xml,v retrieving revision 1.1.2.4 diff -u -p -w -r1.1.2.4 schema.xml --- schema.xml 9 Sep 2008 10:20:24 -0000 1.1.2.4 +++ schema.xml 9 Sep 2008 11:29:05 -0000 @@ -216,6 +216,24 @@ + + + + + + + + + + + + + + + + + + @@ -258,6 +276,7 @@ + + +