views:

48

answers:

2

Noob-ish question: I'm looking for a lightweight but decent php way to search all fields of a MySql table, regardless the structure. I first gave it a try on my own with the default mysql select but that's too basic. I'm looking for something that should at least order results by best match (keyword highlighting would be nice too).

I'm surprised by the little info I found googling around. What I found so far is the Zend Framework Lucene implementation but that seems a bit too heavy (building a separate index) for my needs. Before digging into it I was wondering if there's no easier way.

+1  A: 

Because searching is a very complex thing. Think about what you're asking. You want a tiny search engine that can just figure out how your tables are laid out and what's relevant and what order things should go in. If you can invent that, you'll be rich and probably working at Google.

Lucene like you mentioned, or Sphinx search ( http://sphinxsearch.com/ ) are great. MySQL also has a built-in fulltext search which you can find at http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html

But all of those take configuration and implementation. They aren't just going to "know" what you want.

The closest I can think of is to try Google Custom Search ( http://www.google.com/cse/ ). This doesn't look at your database but instead spiders your site and indexes your pages after they are put together dynamically. You don't have to worry about the index because it's all done for you at Google. Of course you still can't customize the ranking (Google determines it) and you give up control of the data but I think it's as close to an "out of the box" solution as you're going to find.

Cfreak
+1  A: 

I am a fan of the Sphider (http://sphider.eu) search engine.

It's relatively light-weight, easy to set up, and it does multiple sites. Much like Google Custom Search, it will not directly search your tables, but rather your pages after they've been dynamically built.

Sphider is not an enterprise solution, but it will work for up to ~10,000 page sites without too much of a performance hit.

wanovak