Link to home
Start Free TrialLog in
Avatar of Member_2_6346575
Member_2_6346575Flag for United Arab Emirates

asked on

PHP Search Algorithm

Here is my issue. I have a database that has (the important fields anyhow) company name, city, zip code, type of business (I.e. plumbing, heating, attorney, auto repair ...etc)

Currently, I can search the database just fine if I ask for a type of business or business name in one search box and a zip code, or city in the second. It's an easy MySql search, but it is not what my boss wants. He would prefer a search box like google has, a single box with a single search button.

The other issue is, he wants the order the results are returned to be by relevance to what the user typed... For example, if a company has HEATING in it's name, like A1 Heating and Cooling, that would show up before, say, Howards Plumbing, that has heating / cooling as one of their specialties in the company type field.

Worse yet, it's impossible to know what a user is going to put in the search box. They could enter 48640 Plumbers (zip code + company type) or they could omit the company type all together.

Do you see where I am going with this? I have to figure out how to take whatever they type in, search for the results and display them in order of relevance. I have no clue how to do this, and searching for tutorials didn't help. Like I said on facebook, I think this is why google hires MIT grads to design their search algorithms and not just some mediocre programmer.

All I have found out so far is I can set full match, keyword match and assign relevance points to each, but have to explode the search, filter out certain words like the, in, of, a, that ... etc, check each word they type against every field and look for matches, and then put it all together determining which fields most closely match what they typed in and return the results.

It's a nightmare, he's not happy with my current search technique of business type and location being separate, and I can't sort those by relevance anyhow, they either come back in order of company name (At least it only returns the ones in the city they're searching for!)

Any help or advice would be awesome.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LajuanTaylor
LajuanTaylor

@AJ1978 - Here's some additional resources that leverage Apache Solr - an open source search platform built upon a Java library called Lucene.

Enterprise search with PHP and Apache Solr (full example)
http://www.ibm.com/developerworks/library/os-php-apachesolr/

Slide indicates the power of Solr
http://www.slideshare.net/lucenerevolution/enhancing-relevancy-through-personalization-semantic-search
Avatar of Member_2_6346575

ASKER

Many Thanks - really appreciated