Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a search functionality in ASP.NET

Tags:

html

asp.net

I have a website, that content (HTML) is generated using ASP.NET C# from an SQL Server database.

Now I want to add a search function on the website so users can search the content. It would bring up a results page with results.

What is the best way to do this?

like image 943
TeaDrinkingGeek Avatar asked Oct 23 '12 21:10

TeaDrinkingGeek


4 Answers

The 2 best solutions:

  • Google Custom Search (GCS)
  • SQL Server (manual)

GCS:

Here you will rely totally on Google. If they index your webpage in 60 days, then good luck. You won't find info which isn't stored, publically like a webpage. Therefore, any content within the login, forget it.

You will also rely on Search Engine Optimization. if you don't optimize your page titles, meta descriptions ect, the search won't be of much use.

Custom SQL Server:

If you put a full text index on your data fields, you can search for your keywords. This is a decent solution, but remember the indexes (otherwise it will be very slow).

I would search for "SQL Server Full text search" for help on this solution.

The benefit here is you have full control and you can access everything.

EDIT:

There are of course many other solutions. I would also suggest looking into Lucene, or some implementations on top of Lucene such as Solr. However all search functionality is usually very difficult and timeconsuming, henceforth my first two suggestions.

In the company I work at we've previously used FAST, and use Apptus today.

EDIT 2:

Today I would advice one solution only: ElasticSearch. It's a great solution; easy to work with; works on all platforms; based on a nice REST api and JSON and is performing very well.

like image 119
Lars Holdgaard Avatar answered Oct 14 '22 00:10

Lars Holdgaard


Microsoft Index Server: http://www.c-sharpcorner.com/UploadFile/sushil%20saini/UsingIndexServer11262005045132AM/UsingIndexServer.aspx

or ...

Google Custom Search: http://www.google.com/coop/cse/

like image 25
Kevin Boucher Avatar answered Oct 14 '22 00:10

Kevin Boucher


Your pages are generated from SQL database. I think its safe to assume that the relevant data also lies in the SQL DB rather than the asp templates or the C# code. To search that data you could write multiple queries to the database, based on the contains("search term") function.

You could have a simple search that executes all those queries and also have advanced search where you can provide checkboxes based on which queries to execute to refine the search.

That would make more sense than doing a raw search over generated content, imo.

like image 39
Hammad Akhwand Avatar answered Oct 13 '22 22:10

Hammad Akhwand


Use Lucene (The Apache Lucene project develops open-source search software).

  1. http://lucene.apache.org/

  2. http://ifdefined.com/blog/post/Full-Text-Search-in-ASPNET-using-LuceneNET.aspx

like image 38
Marjan Nikolovski Avatar answered Oct 14 '22 00:10

Marjan Nikolovski