Closed (won't fix)
Project:
Drupal core
Version:
4.7.0
Component:
search.module
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
9 May 2006 at 15:40 UTC
Updated:
12 Sep 2006 at 14:55 UTC
I've seen some other people on drupal.org and drupalcenter.de with the same problem and nobody has an answer till yet. I worked a bit in the search.module code to find a solution. In my opinion the problem is in line 764 in the '_search_parse_query' function because i built my own query to get data and found out that the query has to look like this '%%word%%' and not '%% word %%' (in code '%% %s %%'). After a night with many tests I've given up and decided to ask for a solution here.
Thanks a lot.
Comments
Comment #1
mbchandar commentedhi,
here is the patch for search.module
*** modules/search.module 2006-05-10 13:51:44.000000000 +0530
--- modules/search.module1 2006-05-10 12:54:45.000000000 +0530
***************
*** 360,364 ****
// With the exception of the rules above, we consider all punctuation,
// marks, spacers, etc, to be a word boundary.
! //$text = preg_replace('/['. PREG_CLASS_SEARCH_EXCLUDE . ']+/u', ' ', $text);
return $text;
--- 360,364 ----
// With the exception of the rules above, we consider all punctuation,
// marks, spacers, etc, to be a word boundary.
! $text = preg_replace('/['. PREG_CLASS_SEARCH_EXCLUDE . ']+/u', ' ', $text);
return $text;
***************
*** 737,741 ****
// Build word-index conditions for the first pass
! $query2 = substr(str_repeat("i.word like '%s' OR ", count($arguments2)), 0, -4);
return array($query, $arguments, $query2, $arguments2, $matches);
--- 737,741 ----
// Build word-index conditions for the first pass
! $query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4);
return array($query, $arguments, $query2, $arguments2, $matches);
here is the patch for node.module
*** modules/node.module 2006-05-10 12:55:24.000000000 +0530
--- modules/node.module1 2006-05-10 12:53:44.000000000 +0530
***************
*** 698,702 ****
// Do search
- $keys=str_replace("*","%",$keys);
$find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. $join1 .' INNER JOIN {users} u ON n.uid = u.uid', $conditions1 . (empty($where1) ? '' : ' AND '. $where1), $arguments1, $select2, $join2, $arguments2);
--- 698,701 ----
save this patch and patch the node.module and search.module file.
it will work
Comment #2
aamercado commentedI need search with wildcards in drupal 4.7!, y tried the patch but not work for me. Any solution? Thanks and sorry for my english!...
Comment #3
Creazion commented@ mbchandar:
thx for the fast support, your patch works great on the site www.happy-faces.de and sorry for my late answer.
Comment #4
RobRoy commented@mbchandar: Can you submit a proper patch according to http://drupal.org/diffandpatch ? I'm not sure if completely commenting out that first line is the way to go as it will remove all word boundary catching?
Comment #5
Steven commentedWildcard support was removed intentionally. It destroyed database performance. Stemming is preferred instead.
Comment #6
RobRoy commentedSo is stemming in place currently? What should users do if they want wildcard functionality at the sake of a huge db hit?
Comment #7
whereisian commentedI tried to apply the patch but got the following:
for search.module.patch:
for node.module.patch:
Any ideas? Stemming won't do for the type of searches we need.
Comment #8
giorgoskpost #1 patch means
in search.module
comment out line 362 out like this
//$text = preg_replace('/['. PREG_CLASS_SEARCH_EXCLUDE . ']+/u', ' ', $text);
replace "=" with "like" in line 739 like this
$query2 = substr(str_repeat("i.word like '%s' OR ", count($arguments2)), 0, -4);
and
add following line after line 699 in node.module
$keys=str_replace("*","%",$keys);
so if patching is not working for you go ahead and patch both modules by hand