Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: restrict the search just to the contents of the page


Message #1 by "Stephen Biggerstaff" <stephenb@w...> on Wed, 31 Jan 2001 22:40:56 -0000
From Awais_bajwa@y...





Hi there  !! 



is there anyone can help me on this issue please 



i am using the index server for the search but the problem with that is ,

that i can't restrict the search just to the contents of the page in other

words i just need the search within the body tags. Actually what happens

when i typed in a keyword for the search even that word doesn't exist in

the contents of the page but it is in the page in the form of an image or 

some other text. it still gives you the search results. So if the keyword

exsits in the contents then its fine but if the keyword is in  page in the

form of images  or some other texts then i want restrict it.if anyone

knows how to do that can you please email me back . CODE IS DOWN THERE. IF

U FEELING DIFFCULITY TO READ THIS CODE PLEASE CUT AND PASTE IN AN ASP PAGE



 Bundles of thanks in advance 



Awais Bajwa





'------------------------------------------------------- '

searchresults.asp - generic text index search results.

'------------------------------------------------------- On Error Resume

Next Dim objQuery, objUtil, myquery, sPath, sTitle, sFilename,

sDescription, sSection, iRank, sCatalog, sKeywords, bResultsFound Set

objQuery = Server.CreateObject("ixsso.query") Set objUtil 

Server.CreateObject("ixsso.util") bResultsFound = false sCatalog = trim(

Request.querystring( "cat" )) sKeywords = replace(

trim(cstr(request.querystring( "kwd" ))), "'", "''" ) if len( sCatalog ) >

0 and len( sKeywords ) > 0 then ' keyword search objQuery.catalog 

sCatalog objQuery.Query= "$contents " & sKeywords & " and #filename *.asp

" & _ " and not #filename section*.asp and not #filename archive*.asp " &

_ " and not #filename default*.asp and not #filename home.asp"

objQuery.Columns = "Vpath, DocTitle, Filename, Characterization, Rank"

objQuery.SortBy = "Rank [d]" objQuery.MaxRecords = 50

objUtil.AddScopeToQuery objQuery, "/", "DEEP" linebr="

" & vbcrlf Set rstemp = objQuery.CreateRecordSet("nonsequential") if

err.Number <> 0 then bResultsFound = False elseif rstemp.eof = false then

bResultsFound = True DO UNTIL rstemp.eof FOR EACH key in rstemp.fields

keyname=lcase(key.name) SELECT CASE keyname CASE "vpath" sPath = key

sSection = key if InStrRev(sSection, "/" )> 2 then sSection = mid(

sSection, 2, InStrRev(sSection, "/" ) - 2) sSection = replace( sSection,

"+", " " ) sSection = UCase( left( sSection, 1)) & right( sSection, Len(

sSection ) - 1 ) sSection = "" & sSection & "

" else sSection = "" end if CASE "doctitle" sTitle = key CASE "filename"

sFilename = key CASE "characterization" if Len( key ) > 0 then

sDescription = key & "..." else sDescription = key end if sDescription 

Replace( sDescription, "Keyword Search:. find. ", "" ) sDescription 

Replace( sDescription, "SEARCH. ", "" ) sDescription = Replace(

sDescription, "Go. ", "" ) sDescription = Replace( sDescription, "Keyword:

", "" ) CASE "rank" iRank = key Case else END SELECT NEXT response.write

"" & sTitle & "

" response.write sSection response.write sDescription & "



" rstemp.movenext LOOP else ' If rsTemp.eof bResultsFound = false end if

rstemp.close set rstemp=nothing Set objQuery = nothing Set objUtil 

nothing end if ' If catalog and keywords found if bResultsFound = false

then








  Return to Index