幾天後,我幾乎放棄,但在半夜,我有一個絕妙的主意,讓這一切工作。如果我在以64位模式運行的網絡服務器上的子域中進行ajax調用,並且虛擬目錄包含以32位應用程序模式運行的網站的索引目錄。
第二天,我不得不開始工作,在IIS7中添加了一個新的子域,將虛擬目錄添加到網站的索引目錄中。並添加了一個包含請求處理程序的'indexer.asp'頁面。
dim FSOA 'return documents file array
'search inside documents
sub DoSearchText(target, indexservice)
'target = search string
'indexservice = catalog name (index service)
dim IndexArray() 'one dimensional array for index result
dim xmlhttp, tempArray, IndexUrl
'url to the 64bit indexer subdomain
IndexURL = ("http://indextest.subdomain.local/indexer.asp?Index="&IndexService&"&Search="&target&"&Size=50")
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", IndexURL, false
xmlhttp.send ""
if xmlhttp.status >= 400 and xmlhttp.status <=599 then
response.write " error processing: " &xmlhttp.status &" - "&xmlhttp.statusText
else
tempArray= xmlhttp.responseText
end if
set xmlhttp = nothing
'put result into a array
FSOA= split(tempArray,"|")
end Sub
call DoSearchText("chapter one", "sitebooks")
if isarray(FSOA) then
dim docloop
for each docloop in FSOA
response.write "<div>"&docloop&"</div>"
next
else
response.write "No documents found"
end if
`
說明:
- 解析索引服務目錄,
<%@ Language=VBScript %><%
Option explicit
response.buffer=true
dim RequestIndex, strFileError, RequestSearchString, FSOA, RequestMax
RequestIndex=request.querystring("Index")
RequestSearchString=request.querystring("Search")
RequestMax=request.querystring("Size")
' INDEXER
sub DoIndexSearch(target, RequestIndex)
dim foundfilearray:foundfilearray=false
dim ixQuery ' Index Server query object.
set ixQuery = Server.CreateObject("ixsso.Query")
if (Err.description <> "") Then
strFileError= ("<div><strong>Query object Error : " & Err.description & ".</strong></div>")
response.write strFileError
Exit sub
end if
ixQuery.Query =(target)
'ixQuery.SortBy = "DocLastSavedTm[d]"
ixQuery.SortBy = "Rank[d]"
ixQuery.Columns = "FileName," 'Parameter: columns returned (one this case a one dimensional array)
ixQuery.LocaleID = 1043 'Parameter: language
ixQuery.MaxRecords =RequestMax 'Parameter: max returned documents
ixQuery.Catalog = RequestIndex 'IndexService ' Which indexing service
' Create a search utility object to allow us to specify the search type as deep,meaning it will search recursively down through the directories
dim util
set util = Server.CreateObject("ixsso.Util")
util.AddScopeToQuery ixQuery, Server.MapPath(RequestIndex), "deep"
if (Err.description <> "") Then
strFileError= ("<div><strong>Search Utility Error : " & Err.description & "</strong></div>")
response.write strFileError
Exit sub
end if
' Run the query (i.e. create the recordset).
dim QueryRS
set queryRS = ixQuery.CreateRecordSet("nonsequential")
' Check the query result. If it timed out or return no records, then show
' an appropriate message. Otherwise, show the hits.
if (Err.description <> "") Then
strFileError= "<div><strong>search error : " & Err.description & "</strong></div>"
response.write strFileError
queryRS.close
set queryRS = nothing
set ixQuery = nothing
set util = nothing
Exit sub
elseif queryrs.recordcount = 0 then
strFileError="<div><strong>no documents found.</strong></div>"
response.write strFileError
queryRS.close
set queryRS = nothing
set ixQuery = nothing
set util = nothing
Exit sub
else
FSOA= QueryRS.getrows()
queryRS.close
set queryRS = nothing
set ixQuery = nothing
set util = nothing
Exit sub
end if
end Sub
call DoIndexSearch(RequestSearchString,RequestIndex)
' TESTING PURPOSE
dim strTestResult
strTestResult= "<html><head></head><body style=""font-family:Verdana, arial"">"
strTestResult=strTestResult& "<h1>Testing 64bit classic asp indexing using windows 2008 64bit server</h1>"
strTestResult=strTestResult& "<h3>Search in index <em>"&RequestIndex&"</em> for <em>"&RequestSearchString&"</em> with max <em>"&requestMax&"</em> results</h3>"
strTestResult=strTestResult& "<p>Using a seperate website running a 64bit classic pool, wich contains a virtual directory named after the Index which contains the path to the directory of the website that is indexed.</p>"
strTestResult=strTestResult& "<p>The returned results is a one dimensional array containing the filenames where searchstring is found in. This array can be passes back using ajax/json</p>"
if isarray(fsoa) then
strTestResult=strTestResult& " <hr>"
strTestResult=strTestResult& "<fieldset><legend>Found items for "&RequestSearchString&" </legend>"
dim xloop:xloop=0
strTestResult=strTestResult& " <ol>"
for each xloop in fsoa
strTestResult=strTestResult& "<li>"&Xloop&" </li>"
next
strTestResult=strTestResult& " </ol></fieldset></body></html>"
strTestResult=strTestResult& "<hr>"
strTestResult=strTestResult& "<h1>AJAX return array</h1>"
else
strTestResult=strTestResult& " no items found"
end if
' response.write strTestResult ' (Remark when done testing)
' END TESTING
' RETURN INDEXING RESULT TO AJAX/JSON CALLER (one dim array)
if strFIleError="" then
xloop=0
dim ajaxresult
for each xloop in FSOA
ajaxresult=ajaxresult & ucase(Xloop) &"|"
next
ajaxresult=Left(ajaxresult,Len(ajaxresult)-1)
response.write ajaxresult
end if
%>
然後,我在32位應用程序模式下運行的網站之一提出的請求頁面名稱,搜索字符串,最大生成文件
- 在子域創建虛擬目錄(命名爲索引目錄)重定向到已收錄
- 添加一個處理請求調用
- 改變現有的請求對象代碼indexer.asp頁目錄的原始位置原網頁製作一個Ajax調用上述子域
優點:
- 建立從ASP經典的網站上投放一個Ajax請求在32位應用程序模式下轉換爲64位應用程序並返回結果。
- 您還可以包含adobe PDF Ifilter(64位)索引PDF和閱讀PDF文件。
- 容易改變現有的asp代碼的網站。細微的變化
- 在單獨的64位池運行索引和子
- 添加多個目錄很容易保持在一個位置
- 使不可能變成可能:運行ASP經典與64位索引服務中的32位應用程序模式
尼斯件調查和+1。我會提出一個問題(例如,如何從32位ASP應用程序中查詢Windows 2008 x64索引服務?)和一個單獨的自我接受答案。 SO上的一些人可能對張貼'文章'有點有趣。您也可以從社區獲得更多有價值的見解。 – Kev 2010-10-11 12:06:49
感謝Kev,改變了這個問題。 – Plippie 2010-10-11 12:53:06
@Bjork我很早以前就已經回答了,並且當時也接受了它。有些mod刪除了我的答案。我再次加入.... – Plippie 2011-08-23 13:38:13