1

I am working on apachesolr search module.

I want to implement wildcard search I have used hook_apachesolr_query_prepare() function to modify apachesolr query but it is not working can any one give me solution.
I have implemented code like this.

I have taken reference from here : https://www.drupal.org/project/apachesolr/issues/1539284

function custommodule_apachesolr_query_prepare(DrupalSolrQueryInterface &$query, &$caller) {

  $search = '';
  $keywords = preg_split("/[\s,]+/", $query->getParam('q')); 

  foreach ($keywords as $keyword) {
    $search .= '*' . strtolower($keyword) . '* ';    
  }

  $query->addParam('defType', 'edismax');  
  $query->replaceParam('q', $search);  

}

ENV: Drupal 7.60 | Solr 3.X

3
  • which drupal version you work with, and wich solr version please?
    – berramou
    Commented Nov 10, 2018 at 20:50
  • drupal 7.60, solr 3.x Commented Nov 11, 2018 at 12:53
  • if you just copied the solrconfig.xml from 3.X folder, add <requestHandler name="drupal" class="solr.SearchHandler" default="true"> mention in the issue page, because it's not added by default in the config example come with search_api_solr module.
    – berramou
    Commented Nov 11, 2018 at 13:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.