Search module, LIKE instead of =
Search module, LIKE instead of =
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
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 =
i have, it still doesnt work
Re: Search module, LIKE instead of =
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.
I've tried the PiSearch module aswell, but same behaviour.
I posted this in the "Feature ideas" forum.
Re: Search module, LIKE instead of =
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
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 =
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?
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

- Posts: 300
- Joined: Tue Mar 04, 2008 10:37 am
Re: Search module, LIKE instead of =
Russ, this doesn't work, because this affects the search keywords in the database, and NOT the data in the database.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
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 =
Maybe I get this wrong ... but isn't that what the option "Use stemming" is meant for?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.
(I myself never used that because it only works in English languange)
Cheers,
Alex
-
christiaans
- Power Poster

- Posts: 300
- Joined: Tue Mar 04, 2008 10:37 am
Re: Search module, LIKE instead of =
Problem is, once again, that I am not using the English language for this page at this moment.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 =
what is "use Stemming" ?
-
faglork
