This might have been discussed earlier but since the search is so bad I couldn't find any even though i tried.
Anyway, my problem is that when searching I would like the search to use SQL's LIKE. As it is now when I'm searching for test is doesn't find "testing" which is normal behaviour in Google for example.
Anyone know if this is supposed to work in Drupal 5.2 ?

I read some post that was 1.5 years old where people discussed that this was a problem but would be fixed in Drupal 4.7. If it happens to still not be fixed is it possible to edit the sql question and add LIKE? In that case, could someone point me to the file?

Thanks in advance
Magnus, Sweden

Comments

CloudCuckoo’s picture

The core search module doesn't do fuzzy searching, consider using either the Fuzzy search module or the SQL Search (Trip Search) module instead.

---------------------------------------------
THE MIND: PHENOMENAL COSMIC POWER... in an itty bitty living space

riper’s picture

Which one do you prefer and why?

Thanks in advance
Magnus

CloudCuckoo’s picture

Trip is long established, familiar to anyone who uses advanced Google searching ("phrases", exclusion of terms and OR searching) and has more complete features including a tweakable scoring system and filtering of results.

Fuzzysearch is a new module, doesn't *yet* implement advanced searching and there's no option of filtering results, though it does include a scoring system. However it is being very actively developed, indexes CCK text fields and, also familiar to anyone who uses Google searching, provides 'Did you mean... ' results when you make a typo in your search terms.

As the modules are right now for a small site I'd use the Fuzzysearch module. For a site with a lot of content and several content types I'd use Trip - simply because I think the advanced search options and results filters are more likely to be used.

Cloudy

PS: There's also a couple of Google Search modules available but I've not played with any of them.

---------------------------------------------
THE MIND: PHENOMENAL COSMIC POWER... in an itty bitty living space

seliqui’s picture

i changed in search.module this:
-----------------------------------------------------------------
change in function "search_parse_query" this line
$query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4);
through this line
$query2 = substr(str_repeat("i.word like '%%%s%%' OR ", count($arguments2)), 0, -4);

and

change in function "_search_parse_query" this line
return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $count);
through this line
return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%%%s%%'", $count);

-----------------------------------------------------------------
unfortunately these 2 functions are not theme_ functions,
therefore you have to change everything in your "modules/search/search.module".
(so don't forget about that if you make an drupal update)

Anonymous’s picture

You saved me a lot of time!

This code works actually for Drupal 6 with minor mods.

on line 834 change :
$query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4);
to
$query2 = substr(str_repeat("i.word like '%%%s%%' OR ", count($arguments2)), 0, -4);

on line 861 change :
return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $num_new_scores, $num_valid_words);
to
return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%%%s%%'", $num_new_scores, $num_valid_words);