Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi.
There's a bug when you try to search for only a part of a word.
If you want to search for the word "tomato"
and you typed in "toma", you get
Fatal error: Uncaught exception 'Exception' with message ' in /var/www/solr/modules/acquia/apachesolr/Drupal_Apache_Solr_Service.php on line 326
Exception: "400" Status: missing_query_string: missing_query_string
When the code gets parsed here
preg_match('/^(:?(.* |))([^ ]+)$/', $keys, $matches);
$first_part = $matches[2];
// Make sure $last_part contains meaningful characters
$last_part = preg_replace('/[' . PREG_CLASS_SEARCH_EXCLUDE . ']+/u', '', $matches[3]);
if ($last_part == '') {
return array();
}
The $first_part has no value,
and the $last_part has "toma"
and when this is called $result = apachesolr_autocomplete_suggest($first_part, $params, 'apachesolr_autocomplete_highlight', $keys, $suggestions_to_return);
Only $first_part is used to generate the query keys to solr. Which is empty. Which gives the above error.
I would love to supply a patch to fix it, but I'm not sure what exactly should be done in this case.