2014年7月13日 星期日

[RESOLVED] How to set function for searching website content?


Hey friends when website has huge posts , contains , stuff so usually you see there is search box where user will type whatever they wanna search on website and according to his search , related contents use to display on page so how to do it ??



It depends where your site gets its data from.  If it is a sql server then use Free Text searching to search for text in your fields and show the results as neccessary.  You might also want to look into Lucene which is an indexing technology you can plug
into various things (including SQL Server I believe).  If your site is just text files or content in aspx files then you'll need something that can index your site and give you a search interface - google do products that do this, and there will be many others
that do this too.  There is no single answer to this, it depends how your site is constructed and where the data comes from.



Hi,


If the website contents is stored on a database, you will need to create a query that searches the fields of the tables that store the content that you want to search. Ex:




SELECT MyTable1.ContentId AS ContentID, MyTable1.Title AS ContentTitle
FROM MyTable1
WHERE MyTable1.MyFieldToSearch1 LIKE '%' + @MySearchString + '%'

UNION ALL

SELECT MyTable2.ContentId AS ContentID, MyTable2.Title AS ContentTitle
FROM MyTable2
WHERE MyTable2.MyFieldToSearch2 LIKE '%' + @MySearchString + '%'


UNION ALL

SELECT MyTable3.ContentId AS ContentID, MyTable3.Title AS ContentTitle
FROM MyTable3
WHERE MyTable3.MyFieldToSearch3 LIKE '%' + @MySearchString + '%'

...

Then you need to call this query either by placing it as StoredProcedure (if the database engine allows it.  MS SQL Server does, but MS Access doesn't, for instance) or by writing it on the codepage/class and calling it.



Hope this helps,



Obe



You can integrate google search for your website.



Hi,




SACHIN2708


Hey friends when website has huge posts , contains , stuff so usually you see there is search box where user will type whatever they wanna search on website and according to his search , related contents use to display on page so how to do it ??


As AidyF suggested depends on different factors. Apart from the suggestions from other members below are few articles that you might find useful:


" This article describes a simple, free, easy to install Search page written in C#. The goal is to build a simple search tool that can be installed simply by placing three files on a website, and that could be easily extended to add all the features
you might need for a local-site search engine.


There are two main parts to a Search engine:



  • the build process, which processes files, indexing their contents and creating the 'catalog'.
  • the search process, which uses the 'catalog' to find the search term and the names of the files it appears in.  "

Source Article -
http://www.codeproject.com/Articles/7579/Static-Site-Search-Engine-with-ASP-NET-C


Creating an ASP.NET Search Engine -
http://www.developerfusion.com/article/4389/create-a-site-search-engine-in-aspnet/


Adding a Search Method and Search View -http://www.asp.net/mvc/tutorials/mvc-5/introduction/adding-search (MVC App)


Hope you find the information useful!


Best Regards!



沒有留言:

張貼留言