Forums
This topic is locked
Build a Search Engine in DW MX with IIS
22 Jul 2003 16:06:26 Jane 77 posted:
<font face='Verdana'></font id='Verdana'><font color=blue></font id=blue>We have an IIS indexer but need to utilize it through Dreamweaver pages.
Does Dreamweaver have a built in function for a search engine? One of
my associates has been looking at the IIS indexer, but it has to be utilized by a page created through DW. He doesn't know the details but he thinks the starting point will be the DW page.
Do you know where to start in DW MX?
Replies
Replied 22 Jul 2003 16:39:34
22 Jul 2003 16:39:34 Vince Baker replied:
I had a lot of fun doing exactly this...
I used the Microsoft Indexing service and needed to build a search and results page. There is nothing in MX as such but you can obviously use it to hand code the page.
I have some sample code here, it is pretty heavy going but i will help if you need it. Contact me via email for assistance...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% 'Obtain keyword from URL
Dim sSearchString
Dim oQuery
sSearchString = Request.Querystring("QU"
'Specify what the catalogue name is on the Index Service
Const SEARCH_CATALOG = "Enter the name of your catalog here"
%>
<% 'Create query and set recordset
Set oQuery = Server.CreateObject("IXSSO.Query"
oQuery.Catalog = SEARCH_CATALOG
oQuery.Query = "@all " & sSearchString & " AND NOT #path *tpl* AND NOT #path _* AND NOT #path *scripts* AND NOT #path *images* AND NOT #path *app* AND NOT #filename *.class AND NOT #path *publicity* AND NOT #path *vti* AND NOT #filename *.asa AND NOT #filename *.css AND NOT #filename *.txt AND NOT ukconnect_template_ver2.asp AND NOT #filename *script.asp"
oQuery.MaxRecords = 200
oQuery.SortBy = "rank[d], HitCount[d]"
oQuery.Columns = "DocAuthor, vpath, DocTitle, docByteCount, DocAppName, HitCount, FileName, Path, Write, Size, Rank, Create, Characterization, DocCategory"
Set oRS = oQuery.CreateRecordSet("nonsequential"
'Get total number of records returned.
Dim strNoRecords
strNoRecords = oRS.recordcount
%>
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
<SCRIPT TYPE="text/javascript">
function checkform() {
var strQU=document.frmSearch.QU
if ((strQU.value==null)||(strQU.value==""
)
{
alert("Please enter a keyword before starting the search"
strQU.focus()
return false
}
return true
}
</script>
</HEAD>
<BODY MARGINWIDTH="0" MARGINHEIGHT="0">
<h1>search results </h1>
<table width="95%" border="0">
<tr>
<td width="12%"> </td>
<td width="88%">
<form method="Get" ONSUBMIT="return checkform();" action="ukconnect_search_results.asp" name="frmSearch">
<p>
<input name="QU" type="text" value size="20" maxlength="255">
<input type="submit" value="Search" name="B1">
</p>
</form>
<p>Your search for <em><font color="#CC0033"><strong><%=Request.Querystring("QU"
%> </strong></font></em>matched <%=strNoRecords%> documents.<br>
<% If Not oRS.EOF Then %>
Results are listed by relevance.<br>
<% End If %>
</p>
<p>
<% 'If no results, show message
If oRS.EOF Then
nomatches
Else 'If search returns results, repeat through each record
Do While Not oRS.EOF
Dim strvpath, strFileName, strDescription, strRank, strDocTitle, strSize, strLastMod, strHitCount, strAppWritten
strvpath = oRS("vpath"
'Full path of file
strFileName = oRS("FileName"
'Name of file
strDescription = oRS("Characterization"
'Meta Description or Index Service generated text
strRank = oRS("Rank"
/ 10 & "%" 'Display percentage of accuracy
strDocTitle = oRS("doctitle"
'Title of Doc if HTML file. Taken from the <Title> tag
strSize = oRS("Size"
& " bytes" 'Size in bytes of doc
strLastMod = FormatDateTime(oRS("Write"
, 1) 'Date of last modification
strHitCount = oRS("HitCount"
'No of times that the keyword was found
strAppWritten = oRS("DocAppName"
'Name of the application the file was created with
%>
<!-- Write results to the page -->
<% 'If the document has no Title or it is the default Enter Title and the doc is not a word doc (word docs will not show doctitle) then display the filename in its place.
If Not oRS("DocTitle"
= "" AND Not oRS("DocTitle"
= "Enter Application Title Here - Enter Page Title Here" AND Not oRS("DocTitle"
= "Untitled Document" AND Not oRS("DocAppName"
= "Microsoft Word 9.0" AND Not oRS("DocAppName"
= "Microsoft Word 8.0" AND Not oRS("DocAppName"
= "Microsoft Word 7.0" AND Not oRS("DocAppName"
= "Microsoft Word 6.0" AND Not oRS("DocAppName"
= "Microsoft Word 5.0" Then %>
<a href="<%=strvpath%>"><%=strDocTitle%></a>
<% Else %>
<a href="<%=strvpath%>"><%=strFileName%></a>
<% End IF %>
(<%=strRank%><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle><br>
<% 'If there is no Meta Description or Index service has not created a description show 'no description available' text
If Not strDescription = "" Then %>
<%=strDescription%>
<% Else %>
<br>
[No Description available] <br>
<% End If %>
<br>
<font size="1">Filename: <%=strFileName%>, Size: <%=strSize%>, Last Modified: <%=strLastMod%>, Hit Count: <font color="#CC0033"><%=strHitCount%></font></font> </p>
<br>
<br>
<% 'Move to next record in recordset results
oRS.MoveNext
Loop
End If
%>
<%
'*******************************************************************************
SUB nomatches ' also includes help on the Index Server Query Language
Response.Write "<tr>" & VbCrLf
Response.Write "<td width=""100"" valign=""top"" align=""right""> </td>" & VbCrLf
Response.Write "<td width=""600"" valign=""top"">" & VbCrLf
Response.Write "<h3>Exceptions:</h3>" & VbCrLf & VbCrLf
Response.Write "<b>'Noise' words:</b><br>" & VbCrLf
Response.Write "These are common words such as: <font color=""#0066CC"">a</font>, <font color=""#0066CC"">an</font>, <font color=""#0066CC"">and</font>, <font color=""#0066CC"">as</font> and others. These words will be ignored by the search engine unless they are part of a Boolean (see below) search.<br>" & VbCrLf
Response.Write "<b>Punctuation marks:</b><br>" & VbCrLf
Response.Write "Punctuation marks such as: <font color=""#0066CC"">; (semicolon)</font>, <font color=""#0066CC"">: (colon)</font>, <font color=""#0066CC"">. (full stop/period)</font>, <font color=""#0066CC"">, (comma)</font> and others are ignored by the search engine.<br>" & VbCrLf
Response.Write "<b>Special Characters:</b><br>" & VbCrLf
Response.Write "To use specially treated characters such as <font color=""#0066CC"">&</font>, <font color=""#0066CC"">|</font>, <font color=""#0066CC"">^</font>, <font color=""#0066CC"">#</font>, <font color=""#0066CC"">@</font>, <font color=""#0066CC"">$</font>, <font color=""#0066CC"">(</font>, <font color=""#0066CC""><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle></font>, in a query, enclose your query in quotation marks (“<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>." & VbCrLf
Response.Write "<br><br>" & VbCrLf
Response.Write "<h3>Search Help:</h3>" & VbCrLf
Response.Write "<b>Case:</b><br>" & VbCrLf
Response.Write "The search engine is case insensitive so the query ""<font color=""#0066CC"">quality report</font>"" will return the same results as ""<font color=""#0066CC"">Quality Report</font>"".<br>" & VbCrLf
Response.Write "<b>Keyword Search:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality Report</font> will return all documents containing the words ""Quality"" and ""Report"". This type of search will return the same results as the Boolean <font color=""#0066CC"">""Quality"" AND ""Report""</font>.<br>" & VbCrLf
Response.Write "<b>Phrase Search:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">""Quality Report""</font> which will only return documents containing ""Quality Report"".<br>" & VbCrLf
Response.Write "<b>Boolean Searches:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality AND NOT Report</font> will return documents containing ""Quality"" but not ""Report"".<br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality AND Report</font> will return documents containing the words ""Quality"" and ""Report"".<br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality OR Report</font> will return documents containing ""Quality"" and also documents containing ""Report"".<br>" & VbCrLf
Response.Write "<b>Proximity Searches:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality NEAR Report</font> will return documents containing the word ""Quality"" NEAR the word ""Report"".<br>" & VbCrLf
Response.Write "<b>Advanced Searches:</b><br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">@size > 1000</font> will return all documents with a size greater than 1KB.<br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">#filename *.doc</font> will return only word documents.<br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">@write > 01/2/1 10:00:00</font> will return only documents modified since the 1st Feb 2001 at 12:00am.<br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">dis*</font> will return all documents containing ""pro"" as part of a word, i.e. ""Procedure"", ""Professor"" and so on.<br>" & VbCrLf
Response.Write "</font>" & VbCrLf
Response.Write "</td>" & VbCrLf
Response.Write "</tr>" & VbCrLf
END SUB
'*******************************************************************************
%>
</td>
</tr>
</table>
</BODY>
</HTML>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
I used the Microsoft Indexing service and needed to build a search and results page. There is nothing in MX as such but you can obviously use it to hand code the page.
I have some sample code here, it is pretty heavy going but i will help if you need it. Contact me via email for assistance...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% 'Obtain keyword from URL
Dim sSearchString
Dim oQuery
sSearchString = Request.Querystring("QU"

'Specify what the catalogue name is on the Index Service
Const SEARCH_CATALOG = "Enter the name of your catalog here"
%>
<% 'Create query and set recordset
Set oQuery = Server.CreateObject("IXSSO.Query"

oQuery.Catalog = SEARCH_CATALOG
oQuery.Query = "@all " & sSearchString & " AND NOT #path *tpl* AND NOT #path _* AND NOT #path *scripts* AND NOT #path *images* AND NOT #path *app* AND NOT #filename *.class AND NOT #path *publicity* AND NOT #path *vti* AND NOT #filename *.asa AND NOT #filename *.css AND NOT #filename *.txt AND NOT ukconnect_template_ver2.asp AND NOT #filename *script.asp"
oQuery.MaxRecords = 200
oQuery.SortBy = "rank[d], HitCount[d]"
oQuery.Columns = "DocAuthor, vpath, DocTitle, docByteCount, DocAppName, HitCount, FileName, Path, Write, Size, Rank, Create, Characterization, DocCategory"
Set oRS = oQuery.CreateRecordSet("nonsequential"

'Get total number of records returned.
Dim strNoRecords
strNoRecords = oRS.recordcount
%>
<HTML>
<HEAD>
<TITLE>Search Results</TITLE>
<SCRIPT TYPE="text/javascript">
function checkform() {
var strQU=document.frmSearch.QU
if ((strQU.value==null)||(strQU.value==""

{
alert("Please enter a keyword before starting the search"

strQU.focus()
return false
}
return true
}
</script>
</HEAD>
<BODY MARGINWIDTH="0" MARGINHEIGHT="0">
<h1>search results </h1>
<table width="95%" border="0">
<tr>
<td width="12%"> </td>
<td width="88%">
<form method="Get" ONSUBMIT="return checkform();" action="ukconnect_search_results.asp" name="frmSearch">
<p>
<input name="QU" type="text" value size="20" maxlength="255">
<input type="submit" value="Search" name="B1">
</p>
</form>
<p>Your search for <em><font color="#CC0033"><strong><%=Request.Querystring("QU"

<% If Not oRS.EOF Then %>
Results are listed by relevance.<br>
<% End If %>
</p>
<p>
<% 'If no results, show message
If oRS.EOF Then
nomatches
Else 'If search returns results, repeat through each record
Do While Not oRS.EOF
Dim strvpath, strFileName, strDescription, strRank, strDocTitle, strSize, strLastMod, strHitCount, strAppWritten
strvpath = oRS("vpath"

strFileName = oRS("FileName"

strDescription = oRS("Characterization"

strRank = oRS("Rank"

strDocTitle = oRS("doctitle"

strSize = oRS("Size"

strLastMod = FormatDateTime(oRS("Write"

strHitCount = oRS("HitCount"

strAppWritten = oRS("DocAppName"

%>
<!-- Write results to the page -->
<% 'If the document has no Title or it is the default Enter Title and the doc is not a word doc (word docs will not show doctitle) then display the filename in its place.
If Not oRS("DocTitle"








<a href="<%=strvpath%>"><%=strDocTitle%></a>
<% Else %>
<a href="<%=strvpath%>"><%=strFileName%></a>
<% End IF %>
(<%=strRank%><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle><br>
<% 'If there is no Meta Description or Index service has not created a description show 'no description available' text
If Not strDescription = "" Then %>
<%=strDescription%>
<% Else %>
<br>
[No Description available] <br>
<% End If %>
<br>
<font size="1">Filename: <%=strFileName%>, Size: <%=strSize%>, Last Modified: <%=strLastMod%>, Hit Count: <font color="#CC0033"><%=strHitCount%></font></font> </p>
<br>
<br>
<% 'Move to next record in recordset results
oRS.MoveNext
Loop
End If
%>
<%
'*******************************************************************************
SUB nomatches ' also includes help on the Index Server Query Language
Response.Write "<tr>" & VbCrLf
Response.Write "<td width=""100"" valign=""top"" align=""right""> </td>" & VbCrLf
Response.Write "<td width=""600"" valign=""top"">" & VbCrLf
Response.Write "<h3>Exceptions:</h3>" & VbCrLf & VbCrLf
Response.Write "<b>'Noise' words:</b><br>" & VbCrLf
Response.Write "These are common words such as: <font color=""#0066CC"">a</font>, <font color=""#0066CC"">an</font>, <font color=""#0066CC"">and</font>, <font color=""#0066CC"">as</font> and others. These words will be ignored by the search engine unless they are part of a Boolean (see below) search.<br>" & VbCrLf
Response.Write "<b>Punctuation marks:</b><br>" & VbCrLf
Response.Write "Punctuation marks such as: <font color=""#0066CC"">; (semicolon)</font>, <font color=""#0066CC"">: (colon)</font>, <font color=""#0066CC"">. (full stop/period)</font>, <font color=""#0066CC"">, (comma)</font> and others are ignored by the search engine.<br>" & VbCrLf
Response.Write "<b>Special Characters:</b><br>" & VbCrLf
Response.Write "To use specially treated characters such as <font color=""#0066CC"">&</font>, <font color=""#0066CC"">|</font>, <font color=""#0066CC"">^</font>, <font color=""#0066CC"">#</font>, <font color=""#0066CC"">@</font>, <font color=""#0066CC"">$</font>, <font color=""#0066CC"">(</font>, <font color=""#0066CC""><img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle></font>, in a query, enclose your query in quotation marks (“<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>." & VbCrLf
Response.Write "<br><br>" & VbCrLf
Response.Write "<h3>Search Help:</h3>" & VbCrLf
Response.Write "<b>Case:</b><br>" & VbCrLf
Response.Write "The search engine is case insensitive so the query ""<font color=""#0066CC"">quality report</font>"" will return the same results as ""<font color=""#0066CC"">Quality Report</font>"".<br>" & VbCrLf
Response.Write "<b>Keyword Search:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality Report</font> will return all documents containing the words ""Quality"" and ""Report"". This type of search will return the same results as the Boolean <font color=""#0066CC"">""Quality"" AND ""Report""</font>.<br>" & VbCrLf
Response.Write "<b>Phrase Search:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">""Quality Report""</font> which will only return documents containing ""Quality Report"".<br>" & VbCrLf
Response.Write "<b>Boolean Searches:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality AND NOT Report</font> will return documents containing ""Quality"" but not ""Report"".<br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality AND Report</font> will return documents containing the words ""Quality"" and ""Report"".<br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality OR Report</font> will return documents containing ""Quality"" and also documents containing ""Report"".<br>" & VbCrLf
Response.Write "<b>Proximity Searches:</b><br>" & VbCrLf
Response.Write "The query, <font color=""#0066CC"">Quality NEAR Report</font> will return documents containing the word ""Quality"" NEAR the word ""Report"".<br>" & VbCrLf
Response.Write "<b>Advanced Searches:</b><br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">@size > 1000</font> will return all documents with a size greater than 1KB.<br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">#filename *.doc</font> will return only word documents.<br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">@write > 01/2/1 10:00:00</font> will return only documents modified since the 1st Feb 2001 at 12:00am.<br>" & VbCrLf
Response.Write "The query <font color=""#0066CC"">dis*</font> will return all documents containing ""pro"" as part of a word, i.e. ""Procedure"", ""Professor"" and so on.<br>" & VbCrLf
Response.Write "</font>" & VbCrLf
Response.Write "</td>" & VbCrLf
Response.Write "</tr>" & VbCrLf
END SUB
'*******************************************************************************
%>
</td>
</tr>
</table>
</BODY>
</HTML>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting