Page 1 of 1

Search module, LIKE instead of =

Posted: Mon Jul 28, 2008 4:59 pm
by grudz
I have been searching for the answer to this question for days now, but to no aveil.

When using the search module, it forces me to put in the textbox the full word i am searching for; can the code be modified to have a LIKE function...or CONTAINS?

Example i have a word that is George, i would like to show the results if i search with "Geo"

Thank you in advance

Re: Search module, LIKE instead of =

Posted: Mon Jul 28, 2008 7:23 pm
by grudz
i have, it still doesnt work

Re: Search module, LIKE instead of =

Posted: Mon Jul 28, 2008 9:53 pm
by sn3p
I too noticed the Search module doesn't support partial word search (or the use of *).
I've tried the PiSearch module aswell, but same behaviour.

I posted this in the "Feature ideas" forum.

Re: Search module, LIKE instead of =

Posted: Tue Jul 29, 2008 3:33 pm
by Russ
Replace the following lines in the Search module file: action.dosearch.php

For a Like comparator try this - it will find 'pig' as well as 'pigs'
line 35:  $q = 'SELECT count FROM '.cms_db_prefix().'module_search_words WHERE word = ?';
with: $q = 'SELECT count FROM '.cms_db_prefix().'module_search_words WHERE word LIKE ?';

line 36: $q = 'UPDATE '.cms_db_prefix().'module_search_words SET count=count+1 WHERE word = ?';
with: $q = 'UPDATE '.cms_db_prefix().'module_search_words SET count=count+1 WHERE word LIKE ?';

I think using much more of a wild card is only going to produce really bad results. I quite like the 'LIKE' one though. I will maybe keep this, what does anyone else think?

Russ

Re: Search module, LIKE instead of =

Posted: Fri Aug 01, 2008 8:47 pm
by grudz
hey russ,

I tried that and go the same results. from what i can see that sql is simply to add the search value into the database.

i saw a little higher up in the code this line :

#$searchphrase = implode(' OR ', array_fill(0, $nb_words, 'word = ?'));

and tried to replace the = with LIKE but it still didnt work.

any ideas?

Re: Search module, LIKE instead of =

Posted: Tue Aug 05, 2008 9:50 am
by christiaans
Russ wrote: Replace the following lines in the Search module file: action.dosearch.php

For a Like comparator try this - it will find 'pig' as well as 'pigs'
line 35:  $q = 'SELECT count FROM '.cms_db_prefix().'module_search_words WHERE word = ?';
with: $q = 'SELECT count FROM '.cms_db_prefix().'module_search_words WHERE word LIKE ?';

line 36: $q = 'UPDATE '.cms_db_prefix().'module_search_words SET count=count+1 WHERE word = ?';
with: $q = 'UPDATE '.cms_db_prefix().'module_search_words SET count=count+1 WHERE word LIKE ?';

I think using much more of a wild card is only going to produce really bad results. I quite like the 'LIKE' one though. I will maybe keep this, what does anyone else think?

Russ
Russ, this doesn't work, because this affects the search keywords in the database, and NOT the data in the database.

And I would love to see a solution for this as well, since I want to find pigs if I search for pig.

Any help would be greatly appreciated.

Re: Search module, LIKE instead of =

Posted: Tue Aug 05, 2008 10:16 am
by faglork
chris-s wrote: And I would love to see a solution for this as well, since I want to find pigs if I search for pig.
Maybe I get this wrong ... but isn't that what the option "Use stemming" is meant for?
(I myself never used that because it only works in English languange)

Cheers,
Alex

Re: Search module, LIKE instead of =

Posted: Tue Aug 05, 2008 10:21 am
by christiaans
Maybe I get this wrong ... but isn't that what the option "Use stemming" is meant for?
(I myself never used that because it only works in English languange)

Cheers,
Alex
Problem is, once again, that I am not using the English language for this page at this moment.

Re: Search module, LIKE instead of =

Posted: Thu Aug 07, 2008 5:52 pm
by grudz
what is "use Stemming" ?

Re: Search module, LIKE instead of =

Posted: Fri Aug 08, 2008 10:08 am
by faglork

Re: Search module, LIKE instead of =

Posted: Tue Sep 02, 2008 3:30 pm
by GDS