Search module, LIKE instead of =

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
grudz
Forum Members
Forum Members
Posts: 66
Joined: Mon Jul 28, 2008 4:54 pm

Search module, LIKE instead of =

Post 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
User avatar
grudz
Forum Members
Forum Members
Posts: 66
Joined: Mon Jul 28, 2008 4:54 pm

Re: Search module, LIKE instead of =

Post by grudz »

i have, it still doesnt work
sn3p
Forum Members
Forum Members
Posts: 169
Joined: Mon Oct 15, 2007 2:27 pm

Re: Search module, LIKE instead of =

Post 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.
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm

Re: Search module, LIKE instead of =

Post 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
User avatar
grudz
Forum Members
Forum Members
Posts: 66
Joined: Mon Jul 28, 2008 4:54 pm

Re: Search module, LIKE instead of =

Post 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?
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

Re: Search module, LIKE instead of =

Post 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.
Last edited by Anonymous on Tue Aug 05, 2008 9:59 am, edited 1 time in total.
faglork

Re: Search module, LIKE instead of =

Post 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
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

Re: Search module, LIKE instead of =

Post 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.
User avatar
grudz
Forum Members
Forum Members
Posts: 66
Joined: Mon Jul 28, 2008 4:54 pm

Re: Search module, LIKE instead of =

Post by grudz »

what is "use Stemming" ?
faglork

Re: Search module, LIKE instead of =

Post by faglork »

GDS
Forum Members
Forum Members
Posts: 81
Joined: Sun Feb 18, 2007 1:26 pm

Re: Search module, LIKE instead of =

Post by GDS »

Post Reply

Return to “Modules/Add-Ons”