Even when spellchecker and suggestions are enabled for apachesolr, they are not working for apachesolr_multisitesearch. You can also see this on drupal.org: it had suggestions before the redesign, but not anymore.


robertDouglass’s picture

This is a result of no form alter being done in the multisite module. Here's a copy-n-paste form alter that can be used for 6.x-2.x (note that this code is in the patch in #817702: Make compatible with apachesolr 2.x #11).

 * Implementation of hook_form_[form_id]_alter().
 * This adds spelling suggestions, retain filters to the search form.
function apachesolr_multisitesearch_form_search_form_alter(&$form, $form_state) {
  if (
$form['module']['#value'] == 'apachesolr_multisitesearch') {
$response = apachesolr_static_response_cache(NULL, 'apachesolr_multisitesearch');
    if (
variable_get('apachesolr_search_spellcheck', TRUE) && $response) {
// Get spellchecker suggestions into an array.
if (isset($response->spellcheck->suggestions) && $response->spellcheck->suggestions) {
$suggestions = get_object_vars($response->spellcheck->suggestions);
        if (
$suggestions) {
// Get the original query and replace words.
$query = apachesolr_current_query(NULL, 'apachesolr_multisitesearch');

          foreach (
$suggestions as $word => $value) {
$replacements[$word] = $value->suggestion[0];
$new_keywords = strtr($query->get_query_basic(), $replacements);

// 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)),
jpmckinney’s picture

Status:Active» Closed (duplicate)
jpmckinney’s picture

Status:Closed (duplicate)» Active

Keeping open for 1.x, actually.

wmostrey’s picture

Status:Active» Needs review
new1.9 KB

Here's the patch, a straight port from the version that's true and tested in 6.2.

pfournier’s picture

Here is a patch that work with apachesolr 1.6