views:

167

answers:

2

I am trying to build a web application in ASP.NET MVC and need build a pretty complex search feature. When a user enters a search term I want to search a variety of data sources which include documents, tables in the database, webpage urls and some APIs like facebook. Any tips, tutorials and hints would be greatly appreciated.

+5  A: 

Your question suggests that you're probably not planing to implement the whole feature from scratch, so here are some links that you may find useful.

  • One (the easiest) option would be to use a third-party search engine (e.g. Google Custom Search, but Bing probably has a similar API). This allows you to search (only) your page using Google and display the results in a customized way. The limiation is that it searches only data displayed on some (linked) pages.

  • A more sophisticated approach is to use some .NET library that implements indexing for you (based on the data you give it). A popular library is for example Lucene.Net. In this case, you give it the data you want to search explicitly (relevant content from web pages, database content, etc.), so you have more control of what is being searched (but it is a bit more work).

Tomas Petricek
+1  A: 

Building the actual search index structures and algorithms is no trivial feat. That's why people use Lucene, Sphinx, Solr, etc. Using google.com, as recommended in the comments, will give you no control and poor matching compared to what you'll get from one of these free search engines, when properly configured and used.

I recomend taking a look at Solr, it gives you the power of Lucene but it's much easier to use, plus it adds several convenience features like caching, sharding, faceting, etc.

SolrNet is a Solr client for .Net, it has a sample ASP.NET MVC app that you can use to see how it works and as a base to your project.

Disclaimer: I'm the author of SolrNet.

Mauricio Scheffer