View Single Post
07-05-2008, 04:58 PM
Join Date: Dec 2007
Location: Orlando, FL
Originally Posted by
This is what I use:
PHP: similar_text - Manual
PHP similar_text() Function
I would definitely encourage you to find something else to process your searches. The similar_text function is night and day slower than using the database to search with. Even Regex Like in MySQL is faster and that's pretty sad. The problem with using similar_text is...
1. You need to load all data you want into PHP (that means you have HUGE memory overhead)
2. It only accepts strings, which means you're forced to throw it into a loop of some sort.
3. It only returns a percentage value, which means you need to either store another array or replace the key for each array item that you're searching through.
4. Once it's all said and done, you have to sort the array, then pop off the number of items you want.
That's dirty. If you ever have to search for anything over say... 100 rows you'll be paying for it horribly, especially if there are a lot of people that are using that search functionality.
Use Lucene. It takes more setup but its far better than any other options out there and once you've set it up once, you know how to set it up way faster the next time. FULLTEXT is easy, but primitive and has significant downfalls, especially if you have a small indexible database or your indexed content has a lot of the same content.
View Public Profile
Send a private message to Rizza
Visit Rizza's homepage!
Find More Posts by Rizza