开发者

Advice on searching with PHP and MySQL

Basically, I got the same problem as this guy but I also need relevancy: PHP 'smart' search engine to search Mysql tables advice

But, I can't use Sphinx or Lucene (shared hosting)...

I can use LIKE but that has not relevancy so does anyone know a good PHP class that does create relevancy?

So I need something that fits this bill:

  • Result relevancy value
  • Match part of words, i.e. "LIKE %searchterm%"
  • Search multiple databa开发者_JAVA技巧se columns
  • Can't use things like Sphinx or Lucene, no supported by my shared hosting...

I'm using the CakePHP framework.


You might be interested in my presentation Practical Full Text Search in MySQL.

I compare performance of several solutions:

  • LIKE predicates
  • MyISAM FULLTEXT indexes
  • Sphinx Search
  • Lucene (or Solr)
  • Google Custom Search Engine
  • Inverted indexes

If you have no opportunity to install a dedicated search engine, I'd recommend using FULLTEXT or Google CSE.

Using LIKE predicates is pretty clearly the worst choice.


I have tried Zend_Search_Lucene, the pure-PHP clone of Apache Lucene, but the PHP version is much too slow at indexing. See my answer to Can I predict how large my Zend Framework index will be? (and some quick Q:s)

Zend_Search_Lucene also hasn't maintained compatibility with new versions of the Apache Lucene index file format. See Using Solr and Zends Lucene port together…


Zend_Search_Lucene is an implementation of Lucene in pure PHP. I use it on a shared hosting website I run.


I ended up using mysql's full-text search in boolean mode. I also append the * operators to each search term.

user input: tom jones

resulting query: match(name,description) against('tom* jones* IN BOOLEAN MODE');

Thanks for everyone's help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜