For the non techies this post won't be of much value. But for those who are, I'd like some comments / feedback (if you have any knowledge in the field)
I've been working on implementing a full text search system. The amount of problems I've incurred have been vast.
My initial goal was to end up with a search system that incorporated the following ideas.
- Search through ProductCode / Title / Description Field
- In relation to Title / Description, implement a ranking system whereby matches of a term in Title, would result in a product being listed on the results page higher than one with matches in Description
- Would search product code without any full text, just a simple like match
- Mysql full text indexes don't handle words less 4 chars (by default) so a search for CPU with match against would turn up nothing. fulltext indexing as aforementioned, disregards words of less than 4 chars, so to CPU would not be indexed
- Dashes were recognized as Operators when they were sometimes just part of a product name/code ~ double quoted term to resolve. As with the earlier problem, as a result the word CPU-DRIVE would return nothing even if there was a product titled: CPU-DRIVE simply because CPU would be split from Drive when the table was indexed & discarded.
CODE
Select *,
MATCH(title) AGAINST('+"SearchTerm"*' IN BOOLEAN MODE)*1.7+
MATCH(description) AGAINST('+"SearchTerm"*' IN BOOLEAN MODE)*0.3
AS score FROM cubecartstore_inventory
WHERE MATCH(title,description) AGAINST('+"SearchTerm"*' IN BOOLEAN MODE)
order by score desc LIMIT 0, 25
MATCH(title) AGAINST('+"SearchTerm"*' IN BOOLEAN MODE)*1.7+
MATCH(description) AGAINST('+"SearchTerm"*' IN BOOLEAN MODE)*0.3
AS score FROM cubecartstore_inventory
WHERE MATCH(title,description) AGAINST('+"SearchTerm"*' IN BOOLEAN MODE)
order by score desc LIMIT 0, 25
So as you can see fulltext doesn't seem to be a fully working solution & I wouldn't recommend simply throwing this code into your website unless you're willing to test it thoroughly & see if it fits the search terms commonly used in your site. As I've found it doesn't work for many used @ mine.
So the search continues for and improved search system for cubecart. I will post more information as I come across it / new methods I try as I try'em. Would like to hear any thoughts from others also!
thanks