Solved

Web Page to Query Microsoft Index Server

Posted on 2001-07-03
5
541 Views
Last Modified: 2012-08-13
How do I make a web page to query Microsoft Index Server?
0
Comment
Question by:Kriscott
5 Comments
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6249139
If I am not mistaking (because I never use Index Server myself) Index Server creates database tables....which you can then query using standard ASP with ODBC connection...

Max.
0
 
LVL 15

Expert Comment

by:a.marsh
ID: 6249154
This link may help you:

http://www.aspalliance.com/glenncook/htx.asp

Ant
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6249209
There are sample pages for IIS that do this -- install them (they should be in the IISADMIN folder) and all the instructions should be there.

There's more than one way to do it, and it takes a little playing around to make it work correctly. But it's not that hard. I've got it working on my servers -- at least, most of the time it works. ;-)
0
 
LVL 1

Accepted Solution

by:
rpolocz earned 100 total points
ID: 6253602
If you are using ASP, you can access the ADO objects for index server directly.  Here is an example:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
<HTML>
<HEAD>

<%
' ********** INSTRUCTIONS FOR QUICK CUSTOMIZATION **********
'
' This form is set up for easy customization. It allows you to modify the
' page logo, the page background, the page title and simple query
' parameters by modifying a few files and form variables. The procedures
' to do this are explained below.
'
'
' *** Modifying the Form Logo:

' The logo for the form is named is2logo.gif. To change the page logo, simply
' name your logo is2logo.gif and place in the same directory as this form. If
' your logo is not a GIF file, or you don't want to copy it, change the following
' line so that the logo variable contains the URL to your logo.
' GENERATION21 MODIFY - banner for search page

        FormLogo = "/images/performBnr.jpg"

'
' *** Modifying the Form's background pattern.

' You can use either a background pattern or a background color for your
' form. If you want to use a background pattern, store the file with the name
' is2bkgnd.gif in the same directory as this file and remove the remark character
' the single quote character) from the line below. Then put the remark character on
' the second line below.
'
' If you want to use a different background color than white, simply edit the
' bgcolor line below, replacing white with your color choice.

'       FormBG = "background = " & chr(34) & "is2bkgnd.gif" & chr(34)
        FormBG = "bgcolor = " & chr(34) & "#FFFFFF" & chr(34)


' *** Modifying the Form's Title Text.

' The Form's title text is set on the following line.
' GENERATION21 MODIFY - title of search page
%>

   
<TITLE>Performance Support Search Form</TITLE>

<%
'
' *** Modifying the Form's Search Scope.
'
' The form will search from the root of your web server's namespace and below
' (deep from "/" ). To search a subset of your server, for example, maybe just
' a PressReleases directory, modify the scope variable below to list the virtual path to
' search. The search will start at the directory you specify and include all sub-
' directories.
' GENERATION21 MODIFY - Name of virual directory containing files to be searched

        FormScope = "/documents"

'
' *** Modifying the Number of Returned Query Results.
'
' You can set the number of query results returned on a single page
' using the variable below.

        PageSize = 10

'
' *** Setting the Locale.
'
' The following line sets the locale used for queries. In most cases, this
' should match the locale of the server. You can set the locale below.

        SiteLocale = "EN-US"

' ********** END QUICK CUSTOMIZATION SECTIONS ***********
%>


      <LINK REL=STYLESHEET HREF="is2style.css" TYPE="text/css">

    <META NAME="DESCRIPTION" CONTENT="Sample ASP query form for Microsoft Index Server v2.0">
    <META NAME="AUTHOR"      CONTENT="Index Server Team">
    <META NAME="KEYWORDS"    CONTENT="query, content, hit">
    <META NAME="SUBJECT"     CONTENT="sample form">
    <META NAME="MS.CATEGORY" CONTENT="Internet">
    <META NAME="MS.LOCALE"   CONTENT="EN-US">
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
<%
' Set Initial Conditions
    NewQuery = FALSE
    UseSavedQuery = FALSE
    SearchString = ""

    QueryForm = Request.ServerVariables("PATH_INFO")

' Did the user press a SUBMIT button to execute the form? If so get the form variables.
    if Request.ServerVariables("REQUEST_METHOD") = "POST" then
        SearchString = Request.Form("SearchString")
        FreeText = Request.Form("FreeText")
        ' NOTE: this will be true only if the button is actually pushed.
        'if Request.Form("Action") = "Go" then
            NewQuery = TRUE
                  RankBase=1000
        'end if
    end if
    if Request.ServerVariables("REQUEST_METHOD") = "GET" then
        SearchString = Request.QueryString("qu")
                FreeText = Request.QueryString("FreeText")
                FormScope = Request.QueryString("sc")
                        RankBase = Request.QueryString("RankBase")
        if Request.QueryString("pg") <> "" then
            NextPageNumber = Request.QueryString("pg")
            NewQuery = FALSE
            UseSavedQuery = TRUE
        else
            NewQuery = SearchString <> ""
        end if
    end if
%>
<SCRIPT LANGUAGE="JavaScript">
function openHelp() {
newHelp=window.open("/help/help1.html","helpWin","width=600,height=350,status=no,toolbar=yes,resizable=yes,scrollbars=yes");
newHelp.focus();
}
function openEmail() {
newEmail=window.open("/email.html","mailWin","width=600,height=350,status=no,toolbar=yes,resizable=yes,scrollbars=yes");
newEmail.focus();
}

function LogoffNavigator() {
self.close();
}
</SCRIPT>

</HEAD>

<BODY <%=FormBG%>>

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 height=18>
<TR>
<TD VALIGN=bottom ALIGN=LEFT>
<A href="JavaScript:LogoffNavigator()"><IMG SRC='../images/ag_close_btn.jpg' BORDER=0 HEIGHT=18></A></TD>
<TD VALIGN=bottom ALIGN=LEFT><A HREF="JavaScript:openHelp()"><IMG SRC='../images/ag_help_btn.jpg' BORDER=0 HEIGHT=18></A></TD>
<TD VALIGN=bottom ALIGN=LEFT><A HREF="JavaScript:openEmail()"><IMG SRC='../images/ag_email_btn2.jpg' BORDER=0 HEIGHT=18></A></TD>
<TD VALIGN=botton ALIGN=LEFT><img src='../images/ag_blank_btn.JPG' width='151' height='18'></TD>
</TR>
</TABLE>

<table border=0 cellpadding=0 cellspacing=0 width=620>
  <tr>
    <td colspan=5 valign=TOP align=LEFT> <img src="../images/gen21_logo.jpg" width=140 height=51 hspace=0 vspace=0 border=0 valign=TOP align=LEFT alt="Performance Support"><img src="../images/gen21_top_perfSpt.gif" hspace=0 vspace=0 border=0 align=LEFT alt="Welcome to Performance Support" width="350" height="52"><img src="../images/agilent_top_right.gif" width=130 height=52 hspace=0 vspace=0 border=0 align=LEFT alt="global page">
    </td>
  </tr>
  <tr>
    <td width=140 valign=TOP align=LEFT>
      <table width="140" border="0" cellpadding="0" cellspacing="0">
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr bgcolor="#00CCCC">
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><img src=../images/agilent_left_bottom.gif width="140" height="21" border=0 alt=""></td>
        </tr>
      </table>
    <td valign=TOP align=LEFT>
      <table border=0 width=20>
        <tr>
          <td width=20>&nbsp;</td>
        </tr>
      </table>
    </td>
    <!--end 20 pixel column for vertical rule-->
    <td colspan=3 width=450 align=LEFT valign=TOP>
      <table width="75%">
        <tr>
          <td> <br>
            <b><font face="Verdana, Arial, Helvetica, sans-serif" size="-1">Search
            for information and procedures to assist you in the performance of
            your job. You do not need to log on to return to this page. You may
            bookmark this page at any time. </font></b>
            <p>
            <form action="<%=QueryForm%>" method=POST>
              <table width="75%" cellspacing="1" cellpadding="1">
                <tr>
                  <td colspan="2"><b><font face="Verdana, Arial, Helvetica, sans-serif">What
                    do you want to find? </font></b><font face="Verdana, Arial, Helvetica, sans-serif"><br>
                    <font size="-1">Enter your query then click Go</font></font></td>
                  <td width="34%">&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="2">
                    <input type="TEXT" name="SearchString" size="50" maxlength="100" value="<%=SearchString%>">
                  </td>
                  <td width="34%">
                    <div align="right">
                      <input type="SUBMIT" name="Action" value="Go">
                    </div>
                  </td>
                </tr>
                <tr>
                  <td width="60%" height="28" valign="top">
                    <input name="FreeText2" type=CHECKBOX
                                                                <% if freetext = "on" then
                                                                                response.write(" checked")
                                                                end if %>>
                    Use <a href="ixtiphlp.htm#FreeTextQueries">Free-Text Query</a>.</td>
                  <td colspan="2" valign="top" height="28">
                    <div align="right"><a href="ixtiphlp.htm">Tips for searching</a></div>
                  </td>
                </tr>
              </table>
            </form>
            <%
  if NewQuery then
    set Session("Query") = nothing
    set Session("Recordset") = nothing
    NextRecordNumber = 1

' Remove any leading and ending quotes from SearchString

        SrchStrLen = len(SearchString)

        if left(SearchString, 1) = chr(34) then
                SrchStrLen = SrchStrLen-1
                SearchString = right(SearchString, SrchStrLen)
        end if

        if right(SearchString, 1) = chr(34) then
                SrchStrLen = SrchStrLen-1
                SearchString = left(SearchString, SrchStrLen)
        end if

    if FreeText = "on" then
      CompSearch = "$contents " & chr(34) & SearchString & chr(34)
    else
      CompSearch = SearchString
    end if

    set Q = Server.CreateObject("ixsso.Query")
        set util = Server.CreateObject("ixsso.Util")

    Q.Query = CompSearch
    Q.SortBy = "rank[d]"
    Q.Columns = "DocTitle, vpath, filename, size, write, characterization, rank"
      Q.MaxRecords = 300


        if FormScope <> "/" then
                util.AddScopeToQuery Q, FormScope, "deep"
        end if

        if SiteLocale<>"" then
                Q.LocaleID = util.ISOToLocaleID(SiteLocale)
        end if

    set RS = Q.CreateRecordSet("nonsequential")

    RS.PageSize = PageSize
    ActiveQuery = TRUE

  elseif UseSavedQuery then
    if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
      set Q = Session("Query")
      set RS = Session("RecordSet")

      if RS.RecordCount <> -1 and NextPageNumber <> -1 then
        RS.AbsolutePage = NextPageNumber
        NextRecordNumber = RS.AbsolutePosition
      end if

      ActiveQuery = TRUE
    else
      Response.Write "ERROR - No saved query"
    end if
  end if

  if ActiveQuery then
    if not RS.EOF then
 %>
            <hr width=80% align=center size=3>
            <p> <%
        LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
        CurrentPage = RS.AbsolutePage
        if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
            LastRecordOnPage = RS.RecordCount
        end if

        Response.Write "Documents " & NextRecordNumber & " to " & LastRecordOnPage
        if RS.RecordCount <> -1 then
            Response.Write " of " & RS.RecordCount
        end if
        Response.Write " matching the query " & chr(34) & "<I>"
        Response.Write SearchString & "</I>" & chr(34) & ".<br>"
        Response.Write "Five red target symbols indicate a highly ranked hit.<br>"
        Response.Write "One red target symbol indicates a low ranked hit.<P>"
 %> <% if Not RS.EOF and NextRecordNumber <= LastRecordOnPage then%>
            <table border=0>
              <colgroup width=105> <% end if %> <% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage

        ' This is the detail portion for Title, Abstract, URL, Size, and
    ' Modification Date.

    ' If there is a title, display it, otherwise display the filename.
%>
              <p> <% ' Graphically indicate rank of document with list of stars (*'s).

      if NextRecordNumber = 1 then
            RankBase=RS("rank")
      end if

      if RankBase>1000 then
            RankBase=1000
      elseif RankBase<1 then
            RankBase=1
      end if

      NormRank = RS("rank")/RankBase

      if NormRank > 0.80 then
            stars = "/images/rankbtn5.gif"
      elseif NormRank > 0.60 then
            stars = "/images/rankbtn4.gif"
      elseif NormRank > 0.40 then
            stars = "/images/rankbtn3.gif"
      elseif NormRank >.20 then
            stars = "/images/rankbtn2.gif"
      else stars = "/images/rankbtn1.gif"

      end if

%>
              <tr class="RecordTitle">
                <td align="right" valign=top class="RecordTitle"> <%= NextRecordNumber%>.
                </td>
                <td><b class="RecordTitle"> <%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
                  <a href="<%=RS("vpath")%>" class="RecordTitle"><%= Server.HTMLEncode( RS("filename") )%></a>
                  <%else%> <a href="<%=RS("vpath")%>" class="RecordTitle"><%= Server.HTMLEncode(RS("DocTitle"))%></a>
                  <%end if%> </b></td>
              </tr>
              <tr>
                <td valign=top align=left> <img src="<%=stars%>"> <br>
                  <%
    ' Construct the URL for hit highlighting
                  WebHitsQuery = "CiWebHitsFile=" & Server.URLEncode( RS("vpath") )
                  WebHitsQuery = WebHitsQuery & "&CiRestriction=" & Server.URLEncode( Q.Query )
                  WebHitsQuery = WebHitsQuery & "&CiBeginHilite=" & Server.URLEncode( "<strong class=Hit>" )
                  WebHitsQuery = WebHitsQuery & "&CiEndHilite=" & Server.URLEncode( "</strong>" )
                  WebHitsQuery = WebHitsQuery & "&CiUserParam3=" & QueryForm
'              WebHitsQuery = WebHitsQuery & "&CiLocale=" & Q.LocaleID
 %> <!-- HIDE  

        GENERATION21 MODIFY - This section is the hits-highlight section, which does
        not presently work

       <a href="/iissamples/issamples/oop/qsumrhit.htw?<%= WebHitsQuery %>"><IMG src="/images/hilight.gif" align=left alt="Highlight matching terms in document using Summary mode."> Summary</a>
                  <br>
                  <a href="/iissamples/issamples/oop/qfullhit.htw?<%= WebHitsQuery %>&CiHiliteType=Full"><IMG src="/images/hilight.gif" align=left alt="Highlight matching terms in document."> Full</a>

       STOP HIDE--> </td>
                <td valign=top> <%if VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%>
                  <b><i>Abstract: </i></b><%= Server.HTMLEncode(RS("characterization"))%>
                  <%end if%>
                  <p> <i class="RecordStats"><a href="<%=RS("vpath")%>" class="RecordStats" style="color:blue;">http://<%=Request("server_name")%><%=RS("vpath")%></a>
                    <br>
                    <%if RS("size") = "" then%>(size and time unknown)<%else%>size
                    <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end if%></i>
                </td>
              </tr>
              <tr> </tr>
              <%
          RS.MoveNext
          NextRecordNumber = NextRecordNumber+1
      Loop
 %>
            </table>
            <p><br>
              <%
  else   ' NOT RS.EOF
      if NextRecordNumber = 1 then
          Response.Write "No documents matched the query<P>"
      else
          Response.Write "No more documents in the query<P>"
      end if

  end if ' NOT RS.EOF


if NOT Q.OutOfDate then
' If the index is current, display the fact %>
            <p> <i><b>The index is up to date.</b></i><br>
              <%end if


  if Q.QueryIncomplete then
'    If the query was not executed because it needed to enumerate to
'    resolve the query instead of using the index, but AllowEnumeration
'    was FALSE, let the user know %>
            <p> <i><b>The query is too expensive to complete.</b></i><br>
              <%end if


  if Q.QueryTimedOut then
'    If the query took too long to execute (for example, if too much work
'    was required to resolve the query), let the user know %>
            <p> <i><b>The query took too long to complete.</b></i><br>
              <%end if%>
            <table>
              <%
'    This is the "previous" button.
'    This retrieves the previous page of documents for the query.
%> <%SaveQuery = FALSE%> <%if CurrentPage > 1 and RS.RecordCount <> -1 then %>
              <td align=left>
                <form action="<%=QueryForm%>" method="get">
                  <input type="HIDDEN" name="qu" value="<%=SearchString%>">
                  <input type="HIDDEN" name="FreeText" value="<%=FreeText%>">
                  <input type="HIDDEN" name="sc" value="<%=FormScope%>">
                  <input type="HIDDEN" name="pg" value="<%=CurrentPage-1%>" >
                  <input type="HIDDEN" name = "RankBase" value="<%=RankBase%>">
                  <input type="submit" value="Previous <%=RS.PageSize%> documents" name="submit">
                </form>
              </td>
              <%SaveQuery = TRUE%> <%end if%> <%
'    This is the "next" button for unsorted queries.
'    This retrieves the next page of documents for the query.

  if Not RS.EOF then%>
              <td align=right>
                <form action="<%=QueryForm%>" method="get">
                  <input type="HIDDEN" name="qu" value="<%=SearchString%>">
                  <input type="HIDDEN" name="FreeText" value="<%=FreeText%>">
                  <input type="HIDDEN" name="sc" value="<%=FormScope%>">
                  <input type="HIDDEN" name = "RankBase" value="<%=RankBase%>">
                  <input type="HIDDEN" name="pg" value="<%=CurrentPage+1%>">
                  <% NextString = "Next "
               if RS.RecordCount <> -1 then
                   NextSet = (RS.RecordCount - NextRecordNumber) + 1
                   if NextSet > RS.PageSize then
                       NextSet = RS.PageSize
                   end if
                   NextString = NextString & NextSet & " documents"
               else
                   NextString = NextString & " page of documents"
               end if
             %>
                  <input type="submit" value="<%=NextString%>" name="submit">
                </form>
              </td>
              <%SaveQuery = TRUE%> <%end if%>
            </table>
            <% ' Display the page number %> Page <%=CurrentPage%> <%if RS.PageCount <> -1 then
     Response.Write " of " & RS.PageCount
  end if %> <%
    ' If either of the previous or back buttons were displayed, save the query
    ' and the recordset in session variables.
    if SaveQuery then
        set Session("Query") = Q
        set Session("RecordSet") = RS
    else
        RS.close
        Set RS = Nothing
        Set Q = Nothing
        set Session("Query") = Nothing
        set Session("RecordSet") = Nothing
    end if
 %> <% end if %> </td>
        </tr>
      </table>
      <p>&nbsp;
    </td>
  </tr>
  <tr>
    <td width=141> </td>
    <td width=20> </td>
    <td width=359> </td>
    <td width=16> </td>
    <td width=112> </td>
  </tr>
</table>
<br>
&nbsp;
<p>&nbsp; </p>
</BODY>
</HTML>

Go to http://presentations.gen21.com/pss/query.asp to see it work.
0
 
LVL 1

Expert Comment

by:rpolocz
ID: 6328344
Thanks for the Correct Answer!  What could I have done to earn an A?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now