gpt4 book ai didi

asp-classic - 需要用 Classic ASP (VB) 替换 Server 2012 上的 MS 索引服务

转载 作者:行者123 更新时间:2023-12-04 03:25:46 24 4
gpt4 key购买 nike

我刚刚将网站从Server 2003 迁移到Server 2012,MS Indexing 服务不可用。
在做一些研究时,我发现 MS Search Service 是“替代品”,因此,我将它安装在 Server 2012 上。除此之外,我还没有找到启用 ASP-Classic (VB) 代码所必需的新的搜索服务对我的文档进行编目,就像索引服务一样。

MS Search Service 是否有能力和灵活性来编目和搜索文档,并以与 MS Indexing Service 相同的方式返回结果?

下面是当前调用 MS 索引服务(在 Windows 2003 服务器上)的代码示例:

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

并且,将按文档列出结果(文档名称、文档文本摘录以及标题、大小),如下图所示:
enter image description here

感谢您提供任何线索和/或替代方案。

最佳答案

这个例子实际上是不正确的。这是行不通的。以下代码:

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

应该在查询结束时真正使用连接对象。花了几个小时想知道为什么 WHERE 子句不起作用。
objRecordSet.Open "SELECT Top 20 " & _
"System.ItemPathDisplay " & _
",System.ItemName " & _
",System.Size " & _
"FROM SYSTEMINDEX " & _
"WHERE SCOPE='file:E:\MANIF\DAAP\AC'", objConnection

这应该可以帮助所有遇到相同困难的人。

关于asp-classic - 需要用 Classic ASP (VB) 替换 Server 2012 上的 MS 索引服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31480586/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com