What is the best way to make a search engine?
Right now I do have methods to be able to find text within a blob for basically any meaningful peice of data. That is, every DAO on this website has a findInText() method and a findbyName() method and can all be access polymorphically for the most part.
So, basically, If i go through everything on the site, construct links and sort them for the most hits, i get a search engine... well no extra database support but this'll probably be very slow.
Or, I could run through everything in the database once and store all the words and their corresponding hits per article, discussion, etc. (disregarding meaningless words like 'the' and 'a', etc.) and then when people search the site, it just selects from this search table(s) of keywords and constructs the links according to what they are. Not too bad either I guess. Or I could do this once and have it add to the search tables everytime someone adds something to the site. Deleting would be easy to take care of too.
But for ultimately reusability, I would rather make a completely generic Search Engine. Something where I can go:
<blockquote><tt><div style="text-align:left">
$searchEngine = new SearchEngine();
$discussionSearchModule =
new DiscussionSearchModule();
$newsSearchModule =
new NewsSearchModule();
$searchEngine->addModule( $discussionSearchModule );
$searchEngine->addModule( $newsSearchModule );
$searchExpression =
new SearchExpression( "Word1 AND Word2" );
$searchEngine->setSearchExpression( $searchExpression );
$results =
$searchEngine->process();
</i>// display results</i>
while( $link = $results->fetch() ) {
$link->display();
echo "some br tags";
}
</div></tt></blockquote>
If only it weren't a dream.. 🙂
Well that's kind of how I want the architecture to look anyhow.. ideas?