Welcome! Log In Create A New Profile

Advanced

Ignore Spaces

Posted by the_goon 
Ignore Spaces
July 19, 2017 09:44AM
Hi

My web pages contain the part numbers of certain products, for example ABC 1234.

However, often customers will search for the part number without the space (ABC1234). This always produces no results.

Is there a way to tell Sphider to ignore the spaces in the search?

Thanks
Tec
Re: Ignore Spaces
July 19, 2017 03:32PM
Not to be done on the fly.

Would be no problem to add into …/search.php something like
$query = str_replace(" ", "", $query);
This would delete all blanks inside the query string.

BUT
The index procedure will have stored
ABC 1234
as two separate keywords
ABC
and
1234
So the search algorithim will not find a keyword ABC1234.

Now you might think to delete the space also during index procedure. Also no good idea, because all spaces would be deleted. Consequently full text would become one word . . . .

Tec
rap
Re: Ignore Spaces
July 20, 2017 05:16PM
Tec is spot on about ignoring spaces in the query string. You would be asking for trouble.

Have you thought about doing the opposite, that is, instead of IGNORING spaces in a search, FORCING a space?

IF your part numbers are ALWAYS exactly three-alpha space four-numeric, then in search.php look for a query string that is EXACTLY seven characters in the format [three alpha][four numeric] and splitting it into [three alpha] SPACE [four numeric].
Sorry, only registered users may post in this forum.

Click here to login