Hello.
I need an opportunity to use wildcard in search queries, in that reason I install Solr 3.5.0 and now trying to enable eDisMax handler in config.
Changed defType to 'edismax' but as I see now, wildcard is not working now. What else should I do?

This is part of modified solrconfig.xml:

<requestHandler name="drupal" class="solr.SearchHandler" default="true">
    <lst name="defaults">
     <str name="defType">edismax</str>
     <str name="echoParams">explicit</str>
     <bool name="omitHeader">true</bool>
     <float name="tie">0.01</float>
     <str name="pf">
        content^2.0
     </str>
     <int name="ps">15</int>

Comments

Nick_vh’s picture

Status: Active » Closed (works as designed)
apachesolr_environment_variable_set($env_id, 'apachesolr_query_type', 'edismax');

It's best to not touch solrconfig and use the variables defined in solr. Use the example above to enable edismax for your specific environment

Georgique’s picture

Title: Enable eDisMax handler for Solr 3.x » Wildcard search using eDisMax handler with Solr 3.x
Component: solrconfig.xml » Miscellaneous
Status: Closed (works as designed) » Active

Now I see in my query defType => 'edismax', but search with wildcard still not working. Can you tell me, what else should I do?
Thanks.

Georgique’s picture

Status: Active » Closed (works as designed)

It seems working now. Thanks for help. =)

damien_vancouver’s picture

I stared at this issue thread a lot while trying to make edismax wildcard searches work.

There are some case sensitivity gotchas!

It turns out that for your search to work your search term MUST be all lower case - even if what you are matching against is upper or mixed case!!.

That is because Solr is not doing analysis on wildcard searches, and I guess the terms are being indexed all lower case. So if your search term has mixed or upper case, even if that's the correct case for what you're searching for... it won't match anything in a wildcard search! (non-wildcard searches will work as you expect).

A concrete example: My search fields were upper case strings like YDGNRYGI3DQNBU. Using edismax to search for the full term, YDGNRYGI3DQNBU worked as you'd expect. But searching for YDG* or *NRY* returned no results! I was stumped! But then I discovered that searching for ydg* and *nry* DID work - which was something I tried late at night out of desperation! Both swearing and relief ensued. So... if it's not working for you, try your search using all lower case and see if that gives you different results!

In the end I got my search working the way I wanted (automatically adding wildcards to each term) using this code. It may be a bad way of doing it, or it may be buggy for you.. but it worked great for my use case.

/**
 * Implements hook_apachesolr_query_alter().
 * 
 * This prepares a search query so it will be found how we expect.  It turns each 
 * word into a wildcard by adding * * around it, and then also converts
 * each word to lowercase.
 */
function yourmodule_custom_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  $search = '';
  $keywords = preg_split("/[\s,]+/", $query->getParam('q'));  
  foreach ($keywords as $keyword) {
    $search .= '*' . strtolower($keyword) . '* ';    
  }
  $query->replaceParam('q', $search);    
}