Maybe Somone Can Help me hear. (sorry for the double post in wish list) I can delete it???
I think I got a hack that might work but could be slow. This would apply to the search modification that searches for products that contain any word in a search phrase. Currently x-cart only shows resluts that match ALL of the Words in your Search phrase.
(the mod under my Name Page 9 its defualt settings are to work like the normal x-cart search if you scroll 1/3 the way down you will see some commented out code follow the instruction to allow this mod to search by term rather than by phrase)
Not sure how to code this as of yet but hear is the concept.
Simply:
(use the seach mod and change commenting for term match)
1. Take the array of search results that are going to be displayed.
2. Add another element to the array so if the array is just ProductID then make it ProductID, Relevance.
3.Now Loop threw each ProductID For every Word that is found: Increment Relevance by 1.001 for the first time each word is found and increment Relevance by .001 for each additional match of that word.
So if one searches for "Ferrari 333 SP"
A. I have a product that has 3 occurances of "ferrari" and 2 occurances of "333" its relevancy score will be 2.005
B. I have a product that has 1 occurance "of ferrari" and 1 occurance of "333" and 1 occurance of "SP" its relevancy score will be 3.003
C. I have a product that has 4 occurances "of ferrari" and 3 occurances of "333" and 3 occurances of "SP" its relevancy score will be 3.010
D.I have a product that has 15 occurances of "ferrari" its relevancy score will be 1.015
Then If you sort by relevancy the results will be ordered as follows.
Products that Match all terms are listed first and those results will automaticly be orderd by the reoccurance of those matching terms.
(aka add 1 for each term that is matched and .001 for the total occuraces of all matched terms.)
If their are products where their is over 999 reoccurances of a Term this methode starts to fail( simply adding a decimal point will fix it up to 9,999 occurances) Probably dont need more than 99 but was playingit safe.
Should not be to hard to modify the existing code to do this.
If you do it right you just modify the current code that finds each term to update the Relevancy. Then you just add one Sort routine to sort the results by relevance.
Its a thought??? Maybe its easy to say hard to do???
__________________
\"Then again it could all be horse crap\"
by some old Guy.
4.013
|