The Beginning of a Search Algorithm

Building a website is easy!

When you have a database full of articles, posts, and reviews… you will want your users and visitors to search your site instead of finding more information by clicking around.  adding a search box is easy, however producing results from your database is a little tougher.

How to build a mini Google search engine

Here is a simple database structure: ID, title, article

let’s say our precious visitors search for “attracting beautiful women”.

we will have to run multiple queries.

The first query is to search all three words in this same order on the title,

then from the article,

then break up the search to and find in title that contains all keywords in any order,

then break up the search term again find in the article that contains all the keywords in any order.

If the above a few queries does not produce a result, then break up the keywords such to begin and as long as the title contains any one of those keywords or the article that contains any one of those keywords… those should produce results.

What if the user types “sdljklodsfeowirdfkljkldfs dsfkl;dfsldsfpioewfjkfdskfjlsdfkljdsfjkl “?

I can’t even begin to pronounce the word!  But if my algorithm doesn’t produce a result, throw in some advertisements!

be kind to your visitors, baby gift and the gift and send them on their way home :-)

Leave a Reply