Can this module search using wildcards like *?

Comments

rooby’s picture

Title: Does this module support wildcard searching using * and ? » Add option to use EDismax query handler
Category: support » feature

Changing focus a little.

There is an issue of interest in relation to this for the apachesolr module here #713142: Add configuration option to a search environment if we want to use Dismax or EDismax.

googletorp’s picture

Is there any plans on integrating wildcard searches for Seach API Solr using EDismax?

codewhisper’s picture

Hi there.

I'm quite confused about the wildcard search option and the use of the Extended DisMax Query Parser (edismax).

Can someone explain what I need to do to use the wirldcard search?

I'm running Solr version 3.6.1 which should come ready with edismax. I also changed the solrconfig.xml to <str name="defType">dismax</str>

Also, I'm not using Views or anything similar. Just wanna query directly by using search_api_query. Maybe someone can give an example.

Thanks!

lex0r’s picture

Is anything done or at least planned to be done here? Any feedback is welcome, the community could draw a patch out of it :)

charlie-s’s picture

I'm currently doing this in hook_search_api_solr_query_alter() to achieve it:

<?php

function hook_search_api_solr_query_alter(array &$call_args, SearchApiQueryInterface $query) {
  // Set the request handler to use the ExtendedDisMax query type.
  // wiki.apache.org/solr/ExtendedDisMax
  $call_args['params']['qt'] = 'dismax';

  // Encapsulate query strings in wildcards.
  $key_array = array();
  foreach (explode(' ', $query->getOriginalKeys()) as $k) {
    $key_array[] = "*$k*";
  }
  $call_args['query'] = implode(' ', $key_array);
}

?>

This is how I have to alter the query in order to get string matching across fields; for example, "foo bar" returning a node with title containing "foo" and field_x containing "bar".

So perhaps putting the asterisk in the search field and setting the query type to dismax as in the example above could let OP achieve this.

I'm new to Solr and am not confident that forcing all wildcards is an acceptable approach. Is it very unperformant? I've seen this example elsewhere but am not sure on the other implications.

drunken monkey’s picture

Category: feature » support
Status: Active » Fixed

All of this has already been supported for more than half a year. The Search API Solr Search module already uses edismax by default. Just use the "direct" parse mode for your Search API query and wildcards, as well as all other special Solr syntax, should work as expected.

charlie-s’s picture

Thanks drunken! admin/config/search/search_api/page and changing the query type to "direct query" did this and I was able to remove my nasty code.

Status: Fixed » Closed (fixed)

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

goz’s picture

Issue summary: View changes

i spend some time to find where the "parse mode" setting was. It was finally noticed by drunken monkey in #1953366: Why keys are enclosed by double quotes?

Just use the "Direct query" parse mode (in the page settings, or in Views under Advanced > Query settings) if you want to use Solr's query syntax. Otherwise, entered words will always be searched as they are entered (except quotes).

I have no page settings, but find it in my view as explained.