CodeIgniter Forums
Close Matches SQL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Close Matches SQL (/showthread.php?tid=27786)



Close Matches SQL - El Forum - 02-20-2010

[eluser]sqwk[/eluser]
I have a search function that pulls data from a database, with quite a few WHERE clauses already. However, I would like to show the user close matches as well, meaning results that don't meet all the conditions, but only a set of core-conditions and as many of the others as possible, sorted by how many are met.

Does it make sense to get the result-set that meets all of the core-conditions and do the rest of the filtering through php—manipulating a possibly very large dataset—or is there a way to do this natively through the query?


Close Matches SQL - El Forum - 02-22-2010

[eluser]rogierb[/eluser]
If you have a MySQL innodb database, you could use match() against() for full-text searching.
Another approach is to do a regexp() in MySQL.

If you do use MySQL manipulating an large result can be done through a stored procedure rather then php.

A couple of techniques to filter data and get close matches is to create wordlists with matching terms like synonyms and typos. Another is regexp or filter through a script. The main problem is to get a first resultset large enough.