Simple little addition.
Enable AJAX Autocomplete for Apache Solr Multisite Search module (http://drupal.org/project/apachesolr_multisitesearch).
Patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

janusman’s picture

Status: Patch (to be ported) » Needs review

Seems simple enough.

You need to mark things as "Needs review" to properly get my attention though =) Making it so.

janusman’s picture

Status: Needs review » Fixed

Committed to HEAD (D7) and D6 branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

DrupalGideon’s picture

Category: task » bug
Status: Closed (fixed) » Needs work

For me, although this patch means that the autocomplete widget appears on the multisite form correctly, it's not actually suggesting words from the other multisites.

janusman’s picture

Category: bug » feature

Drat. I'm not really familiar with apachesolr_multiste and committing that patch was probably premature. To correctly fix this I'd really need to dig in or have someone more familiar with multisite to tell me what special solr params are being put in so I can make the autocomplete work correctly.

For now, should I revert the patch? Or is it better than nothing? Thoughts welcome.

Also, switching from bug report to feature request, since we're working on a feature.

DrupalGideon’s picture

I had a look through the multisite code and it's to do with setting the hash param.

I managed to get the autocomplete to show on both the single search page and the multisite search page by adding

  if (module_exists('apachesolr_multisitesearch')) {
    $query->multisite = TRUE;
  }

into the apachesolr_autocomplete_suggest function (before the modify query) but this isn't quite the desired effect. It only needs to work on the multisite form as in on search/apachesolr_multisitesearch and not search/apachesolr_search.

But by adding the $query->multisite = TRUE; with the multisite module enabled you will get multisite searches.

DrupalGideon’s picture

I just tried a crude approach and got it to work.

In my own custom module, I wrote I set a hook_form_FORM_ID_alter() for the "search_form" and if the $form['module']['#value'] == 'apachesolr_multisitesearch' I did a variable_set to say that I was on the multisite.

I then wrote my own hook_apachesolr_modify_query() and checked if my variable was set to the multisite value, and if so I set $query->multisite = TRUE;

I had to change my custom module weight to -1 in order for it to work, my hook needed to be called before the hook_apachesolr_modify_query() in the apachesolr_multisitesearch module as that is what adds the hash filter.

  • janusman committed 982ed8a on 7.x-1.x
    #976932 by sdemi: Changed AJAX Autocomplete for Apache Solr Multisite...