Those of you that have used the primitive search engine I had in place here, and attempted to look up for more than one word, may have been disappointed by the results, myself included. That's why I have been working on a PHP class to help deliver better results when searching within records in a MySQL table, and I just made it operational today.
Using this class, the search process happens at two levels, automatically: first, it tries to match the whole search string against the records in the database; second, it separates the search string into meaningful segments (most likely words), and loop through them trying to find a match; if at least one of the terms is found in a given record, it is considered and added to the results array, which is ordered according to relevance.
Relevance is measured following this criteria: in the first place, the search will return all results that contain the whole phrase; in second place, we will have all records containing all of the search terms, ordered according the number of occurrences; finally, all records matching at least one of the search terms, ordered in the same fashion.
Among the turn downs, it is still incapable of understanding exclusion operators (i.e. -keyword) or quoted phrases. I'm not really sure if I want to complicate it that much, unless there's real use for those features. So far, I haven't found any records of visitors using operators in their searches.
Keeping track of visitors' searches helps me to understand what kind of information they expect to find here. So, if you care enough to give a hand testing the new search, please try meaningful stuff :)
----
Update (06/20):
You can check the code
here. For some reason, the coloring souce feature is not working properly in my server. But you can download it and check the source.
Archived under:
PHP. |
Permalink |
google |
del.icio.us 
|
digg 