I would like to use Apache Solr instead of MySQL for the autocomplete feature. I also want to contribute and therefore I need some hints.

The apachesolr_autocomplete module is a big help, but I can't get over the fact that the results are single search terms instead of entire title names.

e.g.: The user types lem and Solr returns lemon instead of Lemon Tree.

Any ideas how to handle this?

Comments

markus_petrux’s picture

Category: feature » support
Status: Active » Fixed

I'm afraid this is food for a separate contrib module. One that could replace the autocomplete path of node reference fields with another one that points to a menu callback that performs the queries against the apache solr backend and returns the results to the client-side transparently.

cpojoni’s picture

For this separate module to work, the nodereference.module needs probably a change in function nodereference_autocomplete_process($element, $edit, $form_state, $form)
since '#autocomplete_path' => 'nodereference/autocomplete/'. $element['#field_name'], is predefined and would we overwritten if another field (or widget?) would wrap it.

Wouldn't it be better to test if the value is set like this:

  if (empty($element[$field_key]['#element_validate'])) {
    $element[$field_key]['#element_validate'] = array();
  }
  array_unshift($element[$field_key]['#element_validate'], 'nodereference_autocomplete_validate');
andreiashu’s picture

@cpojoni I'm not really sure what you're trying to do in #2 but I think just overriding the autocomplete path ('nodereference/autocomplete') in a hook_menu_alter would be sufficient. Then you can have your own callback that returns the proper results.

cpojoni’s picture

Changing the autocomplete path globally would also be an option, of course. Great idea, thanks!

Status: Fixed » Closed (fixed)

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