Hi all,
I'm having a little problem with the search functionality in osCommerce. Overall it works really well, but I have a problem with the '-' & ':' symbols. They are used quite frequently in productnames, but here's the problem with an example:
My product is called 'Star Wars: Jedi Knight'.
If the visitor types in 'star wars jedi knight', as is quite common, the search results are 0.
Because those symbols make the productname look better, I would like to do the following:
1) take the search keywords the user has typed in and replace the '-' and ':' symbols with nothing
2) while looking for a match, temporarily strip the actual productnames from the symbols and determine if there is a match
This should ensure that the mentioned search keywords would return the right results.
Does anyone have an idea on how to approach this?
Latest News: (loading..)
Strip '-' and ':' from search keywords
Started by WillemB, Oct 13 2003, 21:35
8 replies to this topic
#1
Posted 13 October 2003, 21:35
"Always the same with men, isn’t it? Looks like a starter handle, works like an off-switch."
- Coupling (BBC Comedy)
- Coupling (BBC Comedy)
#2
Posted 13 October 2003, 22:53
I did something like this a while ago, except my code only got rid of periods and apostrophes. It could easily be changed to include those two symbols (in fact I should probably do that for my store).
Here's the link: http://forums.oscommerce.com/index.php?showtopic=54239&hl=
Here's the link: http://forums.oscommerce.com/index.php?showtopic=54239&hl=
#3
Posted 13 October 2003, 22:56
In fact, I need to update the code to include those things. I just noticed my search isn't finding items with &'s or '-'.
I'll fix this tonight if I get a chance. If not, hopefully soon. It's just one line of code that needs changed, but I want to test it beforehand and whatnot.
I'll fix this tonight if I get a chance. If not, hopefully soon. It's just one line of code that needs changed, but I want to test it beforehand and whatnot.
#4
Posted 13 October 2003, 23:05
Actually I think this will work:
From the code in the thread I linked to, replace:
with
That should work.
From the code in the thread I linked to, replace:
(REPLACE(REPLACE(pd.products_name, '\'', ''), '.', '')
with
(REPLACE(REPLACE(REPLACE(REPLACE(pd.products_name, '\'', ''), '.', ''), '&', ''), '-', '')
That should work.
Edited by delaen, 13 October 2003, 23:07.
#5
Posted 13 October 2003, 23:11
Whoops, I just noticed you said : not &
You should just be able to replace & with : in that line to get the proper result.
You should just be able to replace & with : in that line to get the proper result.
#6
Posted 14 October 2003, 11:41
Thanks a lot, I will test it right away 
I'll let you know!
Regards,
Willem.
I'll let you know!
Regards,
Willem.
"Always the same with men, isn’t it? Looks like a starter handle, works like an off-switch."
- Coupling (BBC Comedy)
- Coupling (BBC Comedy)
#7
Posted 14 October 2003, 12:12
Well... I have something to admit... I'm using MS2 and the ':' symbol is already ignored!!! I haven't tested the other symbols.
However, I cannot use your modifications because I have specifically altered that section of the code in my pages for reasons I can't remember. I've tried to change it, but that gave me errors.
Still, you gave me a few interesting pointers... in my case I just have to change the actual search keywords to omit the special symbols, osCommerce will then correctly match it with the productnames (regardless of special symbols there). I think
However, I cannot use your modifications because I have specifically altered that section of the code in my pages for reasons I can't remember. I've tried to change it, but that gave me errors.
Still, you gave me a few interesting pointers... in my case I just have to change the actual search keywords to omit the special symbols, osCommerce will then correctly match it with the productnames (regardless of special symbols there). I think
"Always the same with men, isn’t it? Looks like a starter handle, works like an off-switch."
- Coupling (BBC Comedy)
- Coupling (BBC Comedy)
#8
Posted 14 October 2003, 21:28
Right. This was done on a pre-MS1 site, so I have no idea what's changed since then. In theory it should still work though.
All it's doing is stripping the punctuation from the search string, and then stripping the punctuation from the product name in the database when searching and comparing the two. I'm sure there are other ways to accomplish that as well.
Good luck!
All it's doing is stripping the punctuation from the search string, and then stripping the punctuation from the product name in the database when searching and comparing the two. I'm sure there are other ways to accomplish that as well.
Good luck!
#9
Posted 24 October 2003, 22:36
Well it has finally been resolved! Here's my solution to the problem:http://forums.oscommerce.com/index.php?showtopic=63053
Seems like there's various ways of creating a problem.. and fixing it
Seems like there's various ways of creating a problem.. and fixing it
"Always the same with men, isn’t it? Looks like a starter handle, works like an off-switch."
- Coupling (BBC Comedy)
- Coupling (BBC Comedy)














