You are here:  » Search

Support Forum



Search

Submitted by Bob on Tue, 2007-10-02 12:17 in

Hi there,

I've been trying to figure out where to adjust the settings for what is to be displayed in the search box on search terms like e.g. Kely's and similar names that have ' in their names. If I remove tapestry normalise function from the GET in search.php I would get Kely/ displayed in the box. I would like to remove / and of course if it is safe to do so to have the original term Kely's displayed in the box if possible.

Many Thanks

Bob

Submitted by support on Tue, 2007-10-02 13:24

Hi Bob,

You'll need to make 2 changes to permit the ' character in search. Firstly, in search.php, look for the existing code on line 4:

$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");

and change this to:

$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.'"):"");

(notice the extra ' in the list of allowed characters in the allow parameter to tapestry_normalise)

Then, in search.php, change line 3, currently:

<input type='text' name='q' size='35' value='<?php print (isset($q)?$q:""); ?>' />

to

<input type='text' name='q' size='35' value='<?php print (isset($q)?htmlentities($q,ENT_QUOTES,$config_charset):""); ?>' />

That should do the trick...

Cheers,
David.

Submitted by Bob on Tue, 2007-10-02 17:08

Thanks David.

Submitted by support on Tue, 2007-10-02 17:09

Hi Bob,

It depends on the sort of prouducts you have. If you have a lot of relevant keywords that are less than 4 characters then it would be worth changing MySQL to include them in the full text index, otherwise I would leave it as it is...

Cheers,
David.

Submitted by Bob on Tue, 2007-10-02 18:07

Thanks for that David.

Submitted by support on Tue, 2007-10-02 18:14

Hi Bob,

The main advantage of the full text index is that not all the words in the query have to be in the product name for it to return a result. For example, if you have a product in your database called:

"Sony DVD1234 Recorder"

..but somebody searches for:

"Sony DVD1234 Player"

..with the FULLTEXT index, MySQL will find that product. With the basic search method, no results would be found because not all the words are in the product name. Furthermore, with the basic method they need to be in the same order! With FULLTEXT, the following would also find that product:

"DVD Recorder DVD1234"

..even though "DVD" isn't in the product name on its own. That is the main reason for using FULLTEXT, so if you are able to configure your MySQL server it would certainly be worth doing. You would then need to modify search.php to make sure that the FULLTEXT index is used to 3 letter search terms. This is controlled by the following code on line 63:

if (strlen($parts[0]) > 3)

Simply change this to:

if (strlen($parts[0]) > 2)

in order to enable FULLTEXT for shorter queries. You will need to re-import all products again as MySQL only builds the index when records are inserted.

Hope this helps!
Cheers,
David.

Submitted by Bob on Tue, 2007-10-02 18:25

Yes the explanation helps. Thanks a lot.

Bob