IIS Index Server - What's wrong with my query?

This is Interesting: Free IT Magazines  
Home > Archive > IIS Index Server > April 2005 > What's wrong with my query?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author What's wrong with my query?
David Raasch via WinServerKB.com

2005-04-22, 7:53 am

Greetings All !

I discovered the existence of this "Index Service" just two days ago. I
don't have much experience running IIS and I sort of "inherited" a box here
at my day-job.

I installed the Index Service and told it what catalog to index. I then
Googled for various ASP scripts designed to do queries on catalogs... and
modified one such script for our use here.

After a bit of testing, I decided to add a few new HTML documents to a new
subdirectory within the catalog. After doing so, I tried searching for
words that I KNOW are written within these files.

The search form failed to pull them up. I tried forcing an Incremental
Scan. Waited until that was done. Did my search again. Nothing. Forced
a Full Rescan. Waited for it to complete. Did my searches again. Nothing.

If I go to the "Indexing Service Query Form" and do a standard query for
one of these words I'm hunting for, it pulls up the new pages successfully!

The code I'm using for my search (which I will post in a moment" seems to
do a query based on "$contents keyword". So, I tried an Advanced Query on
that Indexing Service Query form for $contents mykeyword. And I got the
new pages back!

So my question becomes: What the heck is wrong with this search code? Why
isn't it finding my results?

Here's the code:

<html><head>
<title>Quick Search</title>
</head><body bgcolor="#FFFFFF">
<Form action = "search.asp" method="get">
<center>
<p>
<font face='verdana, arial' size='3'><b>Search for ?:</b></font>
<Input NAME="Keyword" size ="30"><br>
<Input type="submit" value="Go!">
</form>
</center>


<%
if request("Keyword") <> "" Then

Set objQuery = Server.CreateObject("ixsso.query")
Set objUtil = Server.CreateObject("ixsso.util")
my_keyword=request("keyword")

' keyword search
myquery=myquery & "$CONTENTS " & my_keyword


' Exclude specific folders
%>

<!--#include virtual="/search/exclude.asp"-->

<%



response.write(myquery & "<BR><BR>")
objQuery.Query=myQuery
objQuery.Columns = "Vpath, DocTitle, Filename, Characterization,
DocKeyWords, Rank, Create, Write "
'objquery.Columns = "DocTitle, vpath, filename, size, write,
characterization, rank"
objQuery.SortBy = "Rank [d]"
objQuery.MaxRecords = 100
objquery.catalog="Web"
'objUtil.AddScopeToQuery objQuery, "/", "deep"
objquery.LocaleID = objutil.ISOToLocaleID("EN-US")


linebr="<br>" & vbcrlf

' start output table
%>
<table width="60%" border='0' align="center" cellpadding="4" cellspacing=
"0">
<tr><td align='center' colspan='2'><font face='verdana, arial'
size='e'><B>Search results for: &nbsp;&nbsp; <%=my_keyword %
></B></font><BR><BR></td></tr>



<%
Set rstemp = objQuery.CreateRecordSet("nonsequential")
DO UNTIL rstemp.eof
rec_num = rec_num + 1
FOR EACH key in rstemp.fields
keyname=lcase(key.name)
SELECT CASE keyname
CASE "vpath"
my_vpath= key
CASE "create"
my_create = key

CASE "write"
my_write = key

CASE "rank"
my_ranking = key
CASE "doctitle"
my_doctitle = key
CASE "filename"
my_filename = key
CASE "characterization"
my_characterization = key
CASE "dockeywords"
my_dockeywords = key

CASE ELSE
response.write "<b>" & keyname & ":</b>" & linebr
response.write key & linebr
END SELECT
NEXT
response.write "<tr><td align='left' colspan='2'>"
response.write rec_num & ". &nbsp;&nbsp;"
response.write "<a href='" & my_vpath & "' target='_blank'>"
if my_doctitle <> "" Then
response.write "<font face='verdana, arial'>" & my_doctitle &
"</font></a> " & linebr
response.write "<font face='verdana, arial' size='2'
color='#808080'>" & my_vpath & "</font>"
else
response.write "<font face='verdana, arial'>" & my_vpath &
"</font></a> " & linebr
end if
response.write "<BR><BR>"
response.write "<font face='verdana,arial' size='2'><B>Abstract:</B>
&nbsp;&nbsp;" & my_characterization & linebr
response.write "<B>Keywords:</B> &nbsp;&nbsp; " & my_dockeywords &
linebr
response.write "</td></tr><tr>"
iCurrentRanking = my_ranking
If iCurrentRanking > 900 Then
iRanking = 10
ElseIf iCurrentRanking > 800 Then
iRanking = 9
ElseIf iCurrentRanking > 700 Then
iRanking = 8
ElseIf iCurrentRanking > 600 Then
iRanking = 7
ElseIf iCurrentRanking > 500 Then
iRanking = 6
ElseIf iCurrentRanking > 400 Then
iRanking = 5
ElseIf iCurrentRanking > 300 Then
iRanking = 4
ElseIf iCurrentRanking > 200 Then
iRanking = 3
ElseIf iCurrentRanking > 100 Then
iRanking = 2
Else
iRanking = 1
End If

sCurrentRankingAltTag = (iRanking * 10) & " percent match" 'Create an
ALT tag for the ranking image

response.write "<td align='left' width='30%'>"
response.write("<img src='"& iRanking & "bars.png' alt='" &
sCurrentRankingAltTag & " width='80' height='17'><BR>")

response.write "<td align='right' width='70%'>"
response.write "<font face='verdana, arial' size='2'>"
Response.write "<b>Create Date:</b> " & FormatDateTime(my_create, 1)
& linebr
Response.write "<b>Last Modified:</b> " & FormatDateTime(my_write, 1)
& "</font></td></tr>"
response.write "<tr><td colspan=2><hr>"
response.write "</tr>"
rstemp.movenext
LOOP
' clean up
rstemp.close
set rstemp=nothing
Set objQuery = nothing
Set objUtil = nothing
response.write "</table>"
End if
%>
</body>
</html>




The /search/exclude.asp file contains paths and files to exclude. There
are only a few of them. Most were entered after I saw pages being returned
in the results that I didn't want. I entered the exclusions into this file
and then simply refreshed my search and saw that those results had
vanished, so I'm fairly certain the problem is NOT due to this file's
contents.

But, for the sake of debugging, I put a line in there to have it print out
what it thinks the variable "myquery" is. Here's a print-out of that
variable, when I searched for one of the words in a new document...
"Rachel".


Rachel and not #Vpath *\*_* and not #Vpath *\_contents* and not #Vpath *\
_raw* and not #Vpath *\_vti_* and not #Vpath *\_vti_cnf* and not #Vpath *\
phpmysearch* and not #Vpath *\dr4296* and not #filename searchwords.log and
not #filename indexmaster.asp and not #filename index.asp and not #filename
indexold.asp and not #filename *.|(inc|,mdb|,cnt|,class|,toc|,css|,js|)


Can anybody point out to me what I'm doing wrong? Is there any way I
should be adjusting my query? "Rachel" is written in a couple of the new
HTML files as simple text within a webpage's "body" tag.


Thanks!

-= Dave =-
David Raasch via WinServerKB.com

2005-04-22, 7:53 am

I believe I have located my problem.

One of the directory exclusions that I copied into use... one that I
thought was basically set up so that we wouldn't scan various FrontPage-
generated subdirectories that aren't usually content-related... was causing
my pages to be excluded.

The phrase in question was:

and not #Vpath *\*_*

The problem seems to be that the particular subdirectory that my files had
underscores in their names. So this exclusion was leaving them out.

After removing this exclusion, my search appears to be working fine.

-= Dave =-
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com