I want to implement search functionality for a website (assume it is similar to SO). I don't want to use Google search of stuff like that.
My question is:
How do I implement this?
There are two methods I am aware of:
Can anyone tell me which way to go? What are the pros and cons?
Better, are there any better ways to do this?
Just use the site: search operator without specifying anything to search for, as in “site:askleo.com”. If there are results, then the site is in the Google index.
Whether you're a nonprofit or a small business, your website needs a search bar. If you have a Squarespace website, you'll find this really easy to accomplish. Just click the insertion point for where you want to add the search bar, scroll down in the box options to Search, and click. That's it - you're done.
The user clicks the search bar, types in a query, and clicks “search”, the magnifying glass icon. Similar to searching on a search engine like Google, results appear below, based on the closest match available to the word or words used in the query.
Use lucene,
http://lucene.apache.org/java/docs/
Apache Lucene is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application that requires full-text search, especially cross-platform.
It is available in java and .net. It is also in available in php in the form of a zend framework module.
Lucene does what you wanted(indexing of the searched items), you have to keep track of a lucene index but it is much better than doing a database search in terms of performance. BTW, SO search is powered by lucene. :D
It depends on how comprehensive your web site is and how much you want to do yourself.
If you are running a a small website without further possibilities to add a custom search, let google do the work (maybe add a sitemap) and use the google custom search.
If you run a medium site with an sql engine use the search features of your sql engine.
If you run some heavier software stack like J2EE or .Net use Lucene, a great, powerful search engine or its .Net clone lucene.Net
If you want to abstract your search from your application and be able to query it in a language neutral way with XML/HTTP and JSON APIs, have a look at solr. Solr runs lucene in the background, but adds a nice web interface to it.
You might want to have a look at xapian and the omega front end. It's essentially a toolkit on which you can build search functionality.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With