Hey list!  I have written several simple search scripts to retrieve basic data.. that 
is to say I wasn't worried about the actual relevancy of what I was retrieving.  Now I 
need to write a search script that retrieves information based on the search terms in 
order of relevancy.  It doesn't have to feature boolean operations but it does have to 
be fast and flexible.  This is what I have so far.

The database contains:
ID   Description
--   ------------
1   jade gold ring
2   grandmas golden ring with leaves
3   silver and gold diamond bracelet

The user enters the search string:
"ring gold leaves"

I split the string into words and query them separately:
"SELECT ID FROM jewlry WHERE description LIKE \"%ring%\""    returns 1,2
"SELECT ID FROM jewlry WHERE description LIKE \"%gold%\""    returns 1,2,3
"SELECT ID FROM jewlry WHERE description LIKE \"%leaves%\""  returns 2

Then I combine the results into one array and use arraycountvalues() to eliminate 
redundencies and count the number of occurances of each row.  The number of occurances 
of a row should be equal to its relevancy so I sort the array by value:
array (
2 => 3,
1 => 2,
3 => 1);

Hopefully that wasn't too hard to follow.  I as examine my code I get the distinct 
impression that this is an extraordinarily Primative method.  :)  If so do you have 
any suggestions for improving it or can you please point me to resources (tutorials, 
books, websites, etc..) that would help me develope more a sophisticated technique?

Much appreciated!
Kevin Stone
[EMAIL PROTECTED]

Reply via email to