webForumDet fria alternativet

hjälp med indexing service - sökfunktion i asp

ASP

4 svar · 501 visningar · startad av oola

Medlem sedan feb. 2004123 inlägg
Frågan#1

Har kört igång ett index på webservern och vill nu nyttja detta till att utföra sökningar på ett intranet.

koden ser ut såhär (inte gjord av mig):

<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>ASP 101's Index Server Article - Search Page</title>
<meta name="description" content="Search Page">
<meta name="keywords" content="Search Page">
<meta name="author" content="John Peterson">
</head>
<body>

<p>
This is the search page of the sample web content for ASP 101's
Index Server article.
</p>

<form action="search.asp" method="get">
    <input type="text" name="query" />
    <input type="submit" value="Search" />
</form>

<p>
Queries that should return results include:
<a href="?query=component">component</a>,
<a href="?query=cookie">cookie</a>,
<a href="?query=database">database</a>,
<a href="?query=date">date</a>,
<a href="?query=time">time</a>,
<a href="?query=email">email</a>,
<a href="?query=form">form</a>,
<a href="?query=search">search</a>,
etc.
</p>

<%
Dim strQuery   ' The text of our query
Dim objQuery   ' The index server query object
Dim rstResults ' A recordset of results returned from I.S.
Dim objField   ' Field object for loop

' Retreive the query from the querystring
strQuery = Request.QueryString("query")

' If the query isn't blank then proceed
If strQuery <> "" Then
    ' Create our index server object
    Set objQuery = Server.CreateObject("ixsso.Query")

    ' Set it's properties
    With objQuery
        .Catalog    = "Intranet"  ' Catalog to query
        .Query      = strQuery     ' Query text
        .MaxRecords = 10           ' Max # of records to return

        ' What to sort records by.  I'm sorting by rank [d]
        ' which is [d]escending by how pertinent Index Server
        ' thinks the result is.  This way the most applicable
        ' result should be first.
        .SortBy = "rank [d]"

        ' Which columns to return.  Column names must
        ' be the same as the catalog's properties.  Some
        ' of them are: contents, filename, size, path,
        ' vpath, hitcount, rank, create, write, DocTitle
        ' DocSubject, DocAuthor, DocKeywords...
        .Columns = "filename, path, vpath, size, write, " _
            & "characterization, DocTitle, DocAuthor, " _
            & "DocKeywords, rank, hitcount"
    End With

    ' Get a recordset of our results back from Index Server
    Set rstResults = objQuery.CreateRecordset("nonsequential")
    
    ' Get rid of our Query object
    Set objQuery = Nothing

    ' Check for no records
    If rstResults.EOF Then
        Response.Write "Sorry. No results found."
    Else
        ' Print out # of results
        Response.Write "<p><strong>"
        Response.Write rstResults.RecordCount
        Response.Write "</strong> results found:</p>"

        ' Loop through results
        Do While Not rstResults.EOF
            ' Loop through Fields
            ' Formatting leaves something to be desired,
            ' but it'll work for now.  We'll pretty things
            ' up and link to the content in part II.
            For Each objField in rstResults.Fields
                Response.Write "<strong>"
                Response.Write objField.Name
                Response.Write ":</strong> "
                Response.Write rstResults.Fields(objField.Name)
                Response.Write "<br />"
            Next

            ' Spacing between results
            Response.Write "<br />"

            ' Move to next result
            rstResults.MoveNext
        Loop
    End If

    ' Kill our recordset object
    Set rstResults = Nothing
End If
%>

</body>
</html>

Felmeddelandet jag får är:

Error Type:
Server object, ASP 0177 (0x8007045A)
8007045a
/search.asp, line 48

Ngn som kodat på liknande sätt och fått det att fungera?

Medlem sedan feb. 200326 inlägg
#2

Jag har använt scriptet och det fungerade utan problem.
Eftersom ett serverobjekt finns på den rad som felangavs - måste man väl ställa den "fräcka" frågan om du kanske glömt starta Index Server.

/B

Medlem sedan feb. 2004123 inlägg
#3

Okej, men då vet jag att det inte är fel på scriptet iaf.

Jorå, Index Server är startad. Eller måste jag göra ngt mer än att markera servicen och välja start?

Medlem sedan feb. 200326 inlägg
#4

http://support.microsoft.com/kb/q175804/

Kanske kan du hitta hjälp här - det tycks ha med säkerhet att göra.

/B

Medlem sedan feb. 2004123 inlägg
#5

Tack Bengt! Med hjälp av din länk löste det sig.

Det handlade om att standraanvändaren inte hade rättigheter att skapa objektet, behövde bara ändra lite i rättigheterna så fungerade det.

255 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
125 ms — deklarationer (db)
0 ms — hämta statistik (cache)
127 ms — hämta tråd, inlägg och bilagor (db)
124 ms — ändringar (db)