• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Display an excerpt from search results

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
millmatic
Asked:
millmatic
  • 2
1 Solution
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
 
millmaticAuthor Commented:
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
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now