Friday, August 18, 2006

Smarter Search

Right now we have 2 or 3 web apps that allow searches on databases. The problem is, the more search terms you type in, the fewer results you get. The algorithm I've written passes the search string from the web form whole to the db query:

WHERE table.column LIKE $searchstring.

It would be far more useful to parse the search string into (1 or more) terms and present results sorted by how many of the terms match a db record/field.

I remember reading a proposal along these lines on the old ArsDigita site, but no real algorithm or code.

Update November 2007:


MySQL provides a MATCH (fields)...AGAINST (expression)

I have implemented this on one of our apps anyway.

Labels: , , ,