This project is read-only.

Search Function

Topics: Developer Forum
Oct 23, 2006 at 5:47 PM
HI

was wondering how a basic search function can be incorporated into the site for the forum postings and the articles section of the starter kit. Any ideas or links that I can follow for guidance.....

Want to understand how to show a "video" link in the question and answers section so that poeple can see small video's along side the written answers....

thnks

bharat
Mar 2, 2007 at 4:39 PM
You could try the Google Ajax API, which I've got running, though not had time to style yet, but it works very very well
Mar 2, 2007 at 8:59 PM
Hi,

I use a search on my site http://www.skistyle.be I use a search function, based on sql server's full text search.
If you're interested, I will post the code. It is not based on the TBH architecture, but it works :)

grtz

koen
Mar 5, 2007 at 1:11 PM
Hi Vantoko, I'd like to see what you've implemented
Mar 7, 2007 at 2:09 PM
Here we go :

I use the following stored procedure to create unions between items that I wish to search.
I use the ranking option of full text search to put the most important items first.
I also use the same fields in each select.



SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE dbo.Search
(
@text nvarchar(100)
)
AS
SET NOCOUNT ON


SET @text =replace(@text,char(39),char(39)+char(39))
SET @text =replace(@text,char(34),char(34)+char(34))
SET @text = char(34) + @text + char(34)

select top 25 * from (

select 'ShowArticle.aspx?ID=' + convert(nvarchar,articles.ArticleID) as link, articles.abstract as description, articles.title as title, ft.rank as rank from articles
inner join
freetexttable(articles, body, @text) as ft
on articles.ArticleID = ft.key

union all

select 'ShowThread.aspx?ID=' + convert(nvarchar,Posts.PostID) as link, convert(nvarchar(100),posts.body) as description, posts.title as title, ft.rank as rank from posts
inner join
freetexttable(posts, body, @text) as ft
on posts.postID = ft.key


) results
order by results.rank desc



in my asp.net code I have the following :

sqlConnection con = new SqlConnection("mystring");
SqlCommand myCommand = new SqlCommand("Search", con);
myCommand.Parameters.Add("@Text", SqlDbType.NVarChar).Value = mySearch;
myCommand.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

dlResults.DataSource = result;
dlResults.DataBind();


and that's (almost it => I did som HTML stripping and stuff) but this provides some extra info

koen
Mar 12, 2007 at 3:28 PM
Even though I haven't done this myself yet, you may also consider employing DotLucene (http://www.dotlucene.net/) for this.