Thread: Search
View Single Post
Old 07-05-2008, 06:31 PM   #9 (permalink)
CoryMathews
The Acquainted
 
CoryMathews's Avatar
 
Join Date: Nov 2007
Location: USA
Posts: 175
Thanks: 6
CoryMathews is on a distinguished road
Default

Well I have spent the last about 3-4 hours looking into this more and more reading about 15 terrible tutorials and lots from the mysql site and have come up with this search method.

It requires a full text search on the fields given so they must varchars, text fields ect.

Anyways heres the query.

Code:
SELECT *,
  MATCH(`FullName`, `Description`, `Category`)
  AGAINST('".$searchString."') AS Relevance 
  FROM `TestTable` 
  HAVING Relevance > 0.2
  ORDER BY Relevance DESC
");
Running it on about 300 rows seems pretty quick still. The Description field is about a paragraph of text and the other 2 are usually just a word or 2.
(27 total, Query took 0.0015 sec)

Thanks for the help guys it pointed me in the right direction. Also if anyone see's any problems with this please let me know.


Ye the 3 character min is going to be a problem and I am on a shared server right now so I guess I will just have to check before searching and tell the user they must input more then 3 characters.
CoryMathews is offline  
Reply With Quote