Implementing a Search Box using ASP.NET MVC, SQL Server, Entity Framework - asp.net

I have no experience building a search solution, but I'd like to have a search box within my solution and I don't know where to even begin. Are there cool SQL Server tricks that I can use to make my search solution performant (I'm using a hosted SQL 2008 server) I'd love pointers to a multi-step tutorial that starts me off with a simple query search solution...and then layers on more advanced code and features.

You don't actually say whether you need/want a 'spider' to index your site "as is" (like Google; which is useful if your searchable content on each page comes from many different tables/objects/entities) or whether you just want to query EF using full-text-search-like syntax to return a collection of Entities?
If you are interesting in the 'spider' approach - here's a CodeProject article for a small ASP.NET Search Engine "Searcharoo". It is a web-crawling search engine for small-ish sites (it doesn't use a database at all), so it may not be applicable for your situation.
The code is also at searcharoo.codeplex.com and there are 7 articles on how it works/was built at Searcharoo.net (disclaimer: I wrote them; I hope they are interesting/useful).
If you need to search your database directly, you should probably look into SQL Server 2008's Full Text Search feature (assuming LIKE isn't sophisticated enough for your needs). We used info from this article (free registration) to set-up SQL Full Text Search on a work project... no EF in our solution though.
Also, as you might know StackOverflow is built with ASP.NET MVC - they blogged about some problems with SQL 2008 FTS. There's also some info on SQL FTS versus Lucene.NET (which is another search engine you could research) that might be useful.

You might be interested in reading this.

Read this article:
Create a Site Search Engine in ASP.NET
If you don't have to program an engine yourself you could consider using Google Custom Search Engine. There are couple of articles about this:
Using Google Co-op's Custom Search
Engine
Implementing Search in ASP.NET with Google Custom Search
Also could be useful:
Helping Visitors Search Your Site By Creating an OpenSearch Provider

Related

Search with ASP.net and SQL Server 2008

I'm about to embark on the ASP.net project which involves building a pretty powerful search function. The application is very database heavy. Essentially, organisations will be adding a lot of metadata about themselves in the form of multi-selects, free text boxes etc. which are all stored in SQL 2008.
When it comes to search I'm loath to re-invent the wheel. Normally with a content driven site I'd use a component such as Zoom Search or ASP.net Search engine (http://www.aspnetsearchengine.com/UltimateSearch/Features.aspx)
But I don't think these type of content driven search controls are apppropriate for what I need given the data driven nature of the search.
I'm thinking full text search is the way to go but then I'm thinking I'll probably lose a lot of the bells and whistles I'd typically get with a packaged search module like spelling suggestions, document search, synonyms, ignore words etc.
Are there any good hybrid solutions (paid or free) for .net sites that provides these nice features within a search framework of sorts?
Thanks,
Ed
Lucene is pretty highly regarded across a number of languages. It's in use on some pretty large sites too, i know monster.com use it and their search is pretty extensive.
https://lucene.apache.org/
Edit Found some more resources:
Lucene.Net and SQL Server
SQL Server 2008 Full Text Search (FTS) versus Lucene.NET
http://ifdefined.com/blog/post/Full-Text-Search-in-ASPNET-using-LuceneNET.aspx
open source faceted search / guided navigation for ecommerce sites with .net apis

What search tools are available for ASP.NET site?

Is there any good search tools for asp.net I can buy to carry out search indexes easily on data I have in my database?
What I require is something that would carry out a general site search of articles but also faceted search as well. Faceted search is quite important feature.
Thanks.
You can implement facets with Lucene.NET, Solr, Sphinx, FAST, Endeca, probably also Xapian.
None of these will be trivial to integrate though, since they use very different data structures from relational databases. Usually you have to denormalize your data to feed it to a full-text search engine.
SolrNet includes a sample ASP.NET MVC application that shows how to implement facets with Solr.
Disclaimer: I'm the author of SolrNet.
I agree with Mauricio Scheffer, using Solr.NET will help achieve what you want. I implemented a basic ASP.NET web form example around a year back. I found this link to be very useful to get me started: http://crazorsharp.blogspot.co.uk/2010/01/full-text-search-using-solr-lucene-and.html
Using the example (above), I managed to create this (DISCLAIMER: personal site): http://surinder.computing-studio.com/post/2011/01/14/At-Last!-Created-My-Own-eBay-Style-Search-Using-Solrnet.aspx
Lucene .net great http://incubator.apache.org/lucene.net/
Its a .net port of the very popular Java search library Lucene.
Now, I prefer having a stand along search engine to remove the strain from my site. I use Solr which is Java, but you can use SolrSharp http://solrsharp.codeplex.com/ or SolrNet http://code.google.com/p/solrnet/ to intergrate with solr.

Is there an ASP.NET full text search system for websites?

We host websites in a shared hosting environment where Microsoft SQL Server full text searching is not allowed. We would love an ASP.NET API that allowed similar functionality to get around this restriction.
We can't easily install software on the shared servers, so the API would have to be written in ASP.NET.
SQL "like" queries are our alternative and they are fast enough (our websites never exceed more than 50Mb of text) but they don't rank results well, have a dictionary, do stemming etc
For this type of circumstance I'd rely on Google and create a proper sitemap. You can integrate google search right into your website too with Google SiteSearch.
If you need more control over full-text search, you can use features of the RDBMS to support this. You don't say which brand of RDBMS you're using. I assume it's likely Microsoft SQL Server if you're using ASP.NET.
See the docs for Full-Text Search at MSDN.
For other brands of RDBMS, see my answer: How best to develop the sql to support Search functionality in a web application?
Lucene is what we were looking for http://incubator.apache.org/lucene.net/

Best way to create a sitesearch in ASP.NET

Which is the best way to create a site search engine for a dynamic asp.net site with hundreds of dynamic pages. I have seen many products and articles
http://www.karamasoft.com/UltimateSearch/overview.aspx
http://www.sitesearchasp.net
http://www.easysearchasp.net/
http://msdn.microsoft.com/en-us/magazine/cc163355.aspx
http://www.codeproject.com/KB/asp/indexserver.aspx
Priyan,
Another high-quality open-source option would be the .NET port of Lucene
CodeProject - Introducing Lucene
dotlucene
lucene.net
You haven't mentioned Google's SiteSearch "product". Is one of your requirements that you'd like to host the search engine/catalog yourself?
Microsoft also has a product Search Server 2008 Express although I'm not sure if you can install it on any hosting provider.
And (disclaimer: I am the author) there is also a very basic open source project on CodeProject called Searcharoo (also at searcharoo.net). It is really meant as a 'demonstration/learning experience' - hence the six how to articles - but it might suffice for a small dynamic site.
I have used SQL Server Full Text Search for some projects - works well but it's really just searching database content, not a combination of static and dynamic Html/Pdf/Word/Jpg etc documents which a "real" web crawler will do.

Which search technology to use with ASP.NET?

What's your preferred method of providing a search facility on a website? Currently I prefer to use Lucene.net over Indexing Service / SQL Server full-text search (as there's nothing to set up server-side), but what other ways are being used out there?
We used both Lucene.net, Indexing Service and SQL Server full-text. For a project with large and heavy DB search functionality SQL search has an upper hand in terms of performance/resource hit. Otherwise Lucene is much better in all aspects.
Take a look at Solr. It uses Lucene for text indexing, but it is a full blown http server so you can post documents over http and do search using urls. The best part is that it gives you faceted searching out of the box which will require a lot of work if you do it yourself.
you could use google, it's not going to be the fastest indexer but it does provide great results when you have no budget.
dtSearch is one we've often used, but I'm not really that big a fan of it.
A lot of people are using Google's custom search these days; even a couple of banks that I know of use it for their intranet.
If you need to index all the pages of your site (not just the ones Google indexes) or if you want to create a search for your intranet web sites, the Google Mini is pretty sweet. It will cost you some money, but it is really easy to have it up and running within just a couple of hours. Depending on how many pages you need to index it can be expensive though.
I'm using dtSearch and I (kind of) like it. The API isn't the greatest in the world for .NET but it can get the job done and it's pretty fast. And it's cheap, so your boss will like it (~$1,000 US).
The results leave something to be desired as it doesn't do any kind of semantic relevance rankings or anything fancy. It does a better job than anything you can get out of MS SQL server though.
It has a web spider that makes it easy to do quick search apps on a website. If you need to you can use the API to create hooks into your database and to provide item level security - but you have to do the work yourself. Their forum leaves something to be desired as well but maybe people will start posting dtSearch stuff here. :)
Has anyone tried Microsoft search server express?
http://www.microsoft.com/enterprisesearch/serverproducts/searchserverexpress/default.aspx
I haven't tried it yet, but it could potentially be powerful.
From the site it looks primarily geared towards sharepoint users but given its sdk I don't see why you couldn't use it for a regular old site search
I also recommend SOLR. It's easy to set up, maintain, and configure. I've found it to be stable and easy to scale. There's a c# package for interfacing with solr.

Resources