p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 (http://p2p.wrox.com/forumdisplay.php?f=264)
-   -   Anyone created a search module? (http://p2p.wrox.com/showthread.php?t=60958)

doanhvu August 8th, 2007 05:49 PM

Anyone created a search module?
Any created a search module yet?
Please help on how to get started.


jimibt August 9th, 2007 04:03 AM


i created one on my site and use the sqlserver free-text searching facility on that. For simplicity, let's just deal with the current TBH modules. For the Articles and Posts, i just created the index on the Body, Title (and in the case of Articles, also, the Abstract). the sql to do this is illustrated below:

Firstly, create the storage for the indexes and give them appropriate names:

use TBHLocalSqlServer -- the name of the database registered in sqlserver
EXEC sp_fulltext_database 'enable'

use TBHLocalSqlServer -- the name of the database registered in sqlserver
EXEC sp_fulltext_database 'enable'

Next, add the indexes to the storage:

create FULLTEXT INDEX ON dbo.tbh_Articles
Language 0X0
KEY INDEX PK_tbh_Articles ON my_Articles

create FULLTEXT INDEX ON dbo.tbh_Posts
Language 0X0
KEY INDEX PK_tbh_Posts ON my_Posts

And that's the freetext indexes setup. Now you have to create a generic query for these using the Contains() keyword:

i.e (this is not the sql i use, just an illustrative excerpt):

select * from (
select 'ShowArticle.aspx?ID=' + convert(nvarchar,tbh_articles.ArticleID)
+ '&search=' + @search as linkid,
tbh_articles.abstract as descriptiontext,
tbh_articles.title as title, 'article' as source from tbh_articles
where contains(body, @whereclause)
or contains(abstract, @whereclause)
or contains(title, @whereclause)

-- need to do a bit of work on the posts part to remove
-- duplicates and retain single line per post

select 'ShowThread.aspx?ID=' + convert(nvarchar, tbh_Posts.PostID)
+ '&search=' + @search as linkid,
convert(nvarchar(4000), tbh_posts.body) as descriptiontext,
tbh_posts.title as title, 'posts' as source from tbh_posts
where (contains(body, @whereclause)
or contains(title, @whereclause))
and approved=1

) results

(thanks to vantoko for the above idea for the sql). Behind the scenes, i've created a SearchItem BLL and DAL in the same paradigm as THB. I also have a usercontrol composed of a textbox and a button. this basically fires a redirect to my searchpage with the search criteria as parameters.

You can see this running if you go to my test site (see below). suggested search terms (multiple words on a single line) to see it working (i only have a limited amount of data at present) are (but not limited to :D):

bbc itv
mika new york

i'll probably post the source code and full instuctions in a few weeks, but for now i'm in a phase of attempting to deliver a several things so can't really get down to that yet.

Hope the pointers above give enough to get you thinking of approaches.



jimibt August 9th, 2007 05:06 AM

ok - i quickly put together the components of my search module. you can grab it here:


the only 'sticky' point will be the fact that user rights and familiarity with sql server management studio express are pretty much a pre-requisite to setting up the initial free-text indexing side of things. i've tried in my little readme in the zip, to detail the steps and have included the relevant scripts to automate this. however, i just KNOW that it won't be straightfwd for everyone. in this case, i'd urge the 'community' to try and help out those struggling with this admin side of things.

ok -enjoy

[edit] doanhvu, perhaps (if you wanted to) you could share your WebChat code. looks like a good starting point for a basic p2p chat facility). Also, minor issue with SQL, have updated zip to version searchV1.1.zip - redownload to get full amendments



englere August 9th, 2007 10:06 PM

Here's a search article that Marco recently published:


I am not personally a fan of Sharepoint, but it has it's place in a corporate intranet. Also, some hosting companies offer it (like WebHost4Life).

Regarding chat, I made some low-level components for plaintext and encrypted sockets. I wanted to set up a chat server on port 443 because I figured most companies don't block that port and I could use encryption to hide the traffic. But it turns out most modern firewalls used by businesses actually inspect port 443 traffic looking for an SSL session ID so my plan didn't work out.

The only way to pass chat traffic through corporate firewalls is to mask it inside HTTP or HTTPS packets. I didn't implement that yet but it seems plausible. We could stick encrypted base64 data inside a valid HTTP packet and the firewalls should let it through.


vantoko August 11th, 2007 08:14 AM


I tried the live search integration a year ago and I don't really like it.
First of all you are dependant on how live search indexes your site
Second, you need to provide a full dns name and that something that hosting providers don't always like to open on their sites (bad practice) since live search uses dynamic IP adresses, you need to open a whole range of addresses in your firewall (I discussed this with the live product team and they were looking for a solution for this)


doanhvu August 11th, 2007 06:06 PM

As Someone mentioned about the coding for Webchat control, it can be downloaded with full explanation.
Just go to Google with keyword "Asp.net Webchat"

englere August 12th, 2007 12:19 AM

I guess you mean the AJAX chat program by Steve Orr:


This looks terrific! I read Steve's articles in ASP.NET Pro magazine and I love his writing style.

If we used this with SSL it would be private but we'd have to leverage an SSL certificate from our web host provider. I'd like to make something like this with simple encryption that would allow private chats without SSL. We'd probably need a JavaScript encyption/decryption set of functions. That seems doable.


All times are GMT -4. The time now is 01:31 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.