Muhambi
Muhambi

Reputation: 3522

Building Search with Special Searches/Tools

I'm building a website that is basically a "Discover Your City" kind of website (eg, business directory, weather, news...). The main function of my website is just to be a business directory. I've already built a business listing search that populates from a couple mysql tables (there is only about 10,000 businesses in my town, meaning only 10,000 listings, so I don't really have issues with speed and needing to move to Fulltext or Sphinx).

Now, I want to build special searches, meaning a user, instead of typing in "Restaurants" or "Joe's Crab Shack" instead types in "News" or "Weather" and is presented with the current weather in town, or local news. Both news and weather are just pulled from external websites. Google has a good example of this here.

How can I build this? Switch Statements is one way I think but not sure if this will end up as a great solution.

Thanks for all help!

Upvotes: 2

Views: 66

Answers (1)

Kadaan
Kadaan

Reputation: 1194

Make a 'keywords' table to store these special words in. Do a lookup on that table first and if you get zero results run the actual search. As long as you always do exact lookups on an index (WHERE term='$search') instead of using a LIKE, the query should be near instant so there's not much of a performance hit doing two queries.

Upvotes: 1

Related Questions