Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Display an excerpt from search results

Posted on 2007-07-23
3
Medium Priority
?
216 Views
Last Modified: 2012-05-05
I have a full text index that users can search. Everything works fine but I don't know how to go about retrieving and displaying an excerpt where the keywords were found. I would also like to highlight those keywords within the excerpt.

The result would be similar to what is displayed in this site when a search is performed.

I am using classic ASP and MSSQL 2005

Thanks
0
Comment
Question by:millmatic
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Big Monty
ID: 19551368
I assume you know how to get the data from the database and store it into a variable? if so, this should work for you:

keywords = Request.Form("searchKeywords")
results = rs("colNameFromDB")

results = Left(results, 200)       'takes the first 200 characters of the results
arrKeywords = Split(keywords, ",")    'assumes keywords are seperated by commas

for each element in arrKeywords
     if InStr(results, element) > 0 then      'if keyword is in the results excerpt.......
        results = Replace(results, keyword, "<font color=red><b>" & keyword & </b></font>"    'change the keyword to red and bold it
    end if
next

Response.Write results



B.D.
0
 

Author Comment

by:millmatic
ID: 19552040
Thanks, but I forgot to mention that the columns are binary data from file uploads. The files are uploaded into the database as "blob" I used the Full-text Index so that the files can be searched and it does work. I just don't know how to get the excerpt from the file to display in the results.

I will use the script you gave me but I still need to know how I can retrieve the actual type from the file I'm searching.

Thanks ffor your help Big Daddy
0
 
LVL 34

Accepted Solution

by:
Big Monty earned 750 total points
ID: 19552301
ahhh ok, thats going to be tough. Basically you'll need to use the FileStream object and buffer it to a variable, then apply my script above. i know how to buffer it to the screen (just google "asp, write blob to screen") but not to a variable.

maybe others can help.

B.D.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question