4

I have just migrated a website from Server 2003 to Server 2012, and MS Indexing service is not available.
In doing some research, I found that MS Search Service is the 'replacement,' and, as such, I installed it on Server 2012. Beyond this, I haven't found what ASP-Classic (VB) code would be necessary to enable the new Search Service to catalog my documents, as Indexing Service did.

Does MS Search Service have the capability and flexibility to catalog and search documents, and return results in the same way that MS Indexing Service did?

Below is an example of the code that currently calls the MS Indexing Service (on the Windows 2003 server):

<%
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
Dim objUtility

' Retreive the query from the querystring
strQuery = Request.QueryString("CiRestriction")
if strQuery <> "" then
    if Request.QueryString("ExactPhrase") = "Yes" then
    strQuery = """" & strQuery & """"
    end if
end if

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

    ' Set its properties

        objQuery.Catalog    = "Test_Docs"  ' Catalog to query
        objQuery.MaxRecords = 75           ' Max # of records to return
        objQuery.SortBy     = "Rank[d], size"
        objQuery.Columns    = "Characterization, DocTitle, Directory, Filename, Path, Rank, Size, Vpath, Write"

        ' Build our Query: Hide admin page and FPSE pages
        'strQuery = "(" & strQuery & ")" _
        '   & " AND NOT #filename = *admin*" _
        '   & " AND NOT #path *\_vti_*"

        ' Uncomment to only look for files modified last 5 days
        'strQuery = strQuery & " AND @write > -5d"

    ' To set more complex scopes we use the utility object.
    ' You can call AddScopeToQuery as many times as you need to.
    ' Shallow includes just files in that folder.  Deep includes
    ' subfolders as well.
    '

    Set objUtility = Server.CreateObject("IXSSO.Util")
    objUtility.AddScopeToQuery objQuery, "d:\test_shares\test_docs", "deep"
    objQuery.Query = strQuery  ' Query text

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

    ' 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
            ' Pretty is as pretty does... good enough:
            %>
            <%KSize=formatnumber(rstResults.Fields("size"))
            KSize= round(KSize/1024,0)%>
            <p>
            <%'test below using PoorMansIsNull function%>
            <% If PoorMansIsNull(rstResults.Fields("DocTitle")) Or rstResults.Fields("DocTitle")="" Then %>

                <a href="/ams/test_docs<%= PathToVpath(rstResults.Fields("path")) %>"  target="_blank"><%= PathToVpath(rstResults.Fields("filename")) %></a>
               <% Else %>
                <a href="/ams/test_docs<%= PathToVpath(rstResults.Fields("path")) %>" target="_blank"><font size="3"><%= rstResults.Fields("DocTitle") %></font></a>
                <% End If %>

                <br><%= rstResults.Fields("Characterization") %><br>

            <font color="#009900"><%= PathToVpath(rstResults.Fields("path")) %> - <%= KSize %>k<br /></font>
            </p>
            <%

            ' Move to next result
            rstResults.MoveNext
        Loop

        rstResults.MoveFirst
        Response.Write "<pre>"
        'Response.Write rstResults.GetString()
        Response.Write "</pre>"
    End If

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

</body>
</html>
<%
Function PathToVpath(strPath)
    Const strWebRoot = "d:\test_shares\test_docs\"

    Dim strTemp

    strTemp = strPath

    strTemp = Replace(strTemp, strWebRoot, "\")
    strTemp = Replace(strTemp, "\", "/")

    PathToVpath = strTemp
End Function
%>

And, the results would be listed, per document (the name of the document, with excerpt from document text, along with title, size), as illustrated below: enter image description here

Thanks for any leads and/or alternatives.

2 Answers 2

2

This example is in fact incorrect. It does not work. The following code:

objRecordSet.Open "SELECT Top 20 " & _
 "System.ItemPathDisplay " & _
 ",System.ItemName " & _
 ",System.Size " & _
 "FROM SYSTEMINDEX", objConnection & _
 "WHERE SCOPE='file:E:\MANIF\DAAP\AC'"

Should really use the connection object at the end of the query. Spent a few hours wondering why the WHERE clause was not working.

objRecordSet.Open "SELECT Top 20 " & _
 "System.ItemPathDisplay " & _
 ",System.ItemName " & _
 ",System.Size " & _
 "FROM SYSTEMINDEX " & _
 "WHERE SCOPE='file:E:\MANIF\DAAP\AC'", objConnection

This should help all who are having the same difficulty.

1
  • Sure! The code was wrong. I've just corrected it. Thanks.
    – gwarah
    Jun 21, 2017 at 13:50
1

I'm facing the same problem. I've found a MS guide about this issue: Querying the Index with Windows Search SQL Syntax.

I've tested this ASP (Classic) code and ran ok:

<html>
<body>
    Results<br>
<ol>
<%
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';"

'change directory on scope clause
objRecordSet.Open "SELECT Top 20 " & _
     "System.ItemPathDisplay " & _
     ",System.ItemName " & _
     ",System.Size " & _
   "FROM SYSTEMINDEX" & _
   " WHERE SCOPE='file:E:\MANIF\DAAP\AC'", objConnection


objRecordSet.MoveFirst
Do Until (objRecordSet.EOF)
    %>
    <li>
    <strong>Path Display:</strong><%=objRecordSet("System.ItemPathDisplay")%><br>
    <strong>Name:</strong><%=objRecordSet("System.ItemName")%><br>
    <strong>Size:</strong><%=objRecordSet("System.Size")%><br>
    <hr>
    </li>
   <%
   objRecordSet.MoveNext
Loop

objRecordSet.Close
Set objRecordSet = Nothing

objConnection.Close
Set objConnection = Nothing
%>
</ol>
</body>
</html>

Other alternatives:

  1. Try to register asp dll in windows server. For I could see, nobody related success on this approch. See this post;
  2. Create a VM a previous windows version to support your asp. See this MS article.

Hope it could help you.

6
  • I've found this thread related to this issue.
    – gwarah
    Dec 1, 2016 at 16:49
  • Thanks. Which version of Windows Server are you using for this?
    – buck1112
    Feb 1, 2017 at 16:17
  • windows server 2012 standard
    – gwarah
    Feb 2, 2017 at 16:37
  • Thanks. Is this with Windows Search Service vs Windows Search Server enabled? Also, if I have a main folder with subfolders and subfolders containing the documents to be searched, can I add to the scope, as was formerly possible with the old Windows Indexing Service? e.g. my old code was like this (inside of a loop to get the selected subfolder from the form dropdown): For yy=0 to Ubound(ArrStrPathInputCourseName) objUtility.AddScopeToQuery objQuery,"e:\bss_web_shares\bsslecturenotes\"& ArrStrPathInputCourseName(yy) &"\", "deep" Next
    – buck1112
    Feb 8, 2017 at 20:03
  • Well, I'm not involved with these project anymore, but I'm going answer for what I could remember: "Is this with Windows Search Service ... enabled?" . R- Yes and we're using the ancient solution Windows Search server, I believe. About the second question, this is enough: objUtility.AddScopeToQuery objQuery,"/","deep"`. I'm assuming that "/" was mapped to "e:\bss_web_shares\bsslecturenotes\".
    – gwarah
    Jun 21, 2017 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.