php - MySQL.. search using Fulltext or using Like? What is better?


I'm working on a search feature for my application, I want to search all articles in the database. As of now, I'm using aLIKE in my queries, but I want to add a "Related Articles" feature, sort of like what SO has in the sidebar (which I see as a problem if I use Like).

What's better to use for MySQL searching, Fulltext or Like... or anything else I might not know about?

Also, I'm using the Kohana Framework, so If anybody knows an easy way to do fulltext matching using the query builder, I'd appreciate that.





First of all, you have to consider that :

  • MySQL FULLTEXT indexes are only possibles for tables in MyISAM -- not for tables in InnoDB
    • And only InnoDB supports foreign keys, transactions, ...
  • UsingLIKE is generally pretty slow and bad for performances, as it generally means doing a full-scan of the table for each search.

I would really not use any of those two solutions for any kind of big/real/important application...

Instead of those two possibilities, have you considered using a real fulltext indexing/search engine ?

For instance, you might want to take a look at :

Note there is an implementation of Lucene that only requires PHP in Zend Framework : -- might be useful if you cannot install any additionnal software on your server.

People are also looking for solutions to the problem: php - Why must I rewind IteratorIterator


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.