Hit Highlighting of SQL Content Search Results

Hit highlighting is a feature in Microsoft Index Server you can use when querying a document. Hit highlighting generates an HTML page containing a list of the hits showing the exact portions of the document that satisfies your query (if any).

When using SQL to query for content, you can use the hit highlighting feature by using ADO to retrieve the Query Restriction property and using it as the value for the Webhits CiRestriction parameter. See Hit Highlighting with Microsoft Index Server for more information.

Note   This feature is available only for SQL content queries (CONTAINS predicate) and vpath must be present in the Select_List statement. Get the Query Restriction property only after the command is executed.

The following example queries for documents containing the words "Index" and "Server", gets the Query Restriction property, and uses it to invoke the Hit Hightlight feature:

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionString =  "provider=msidxs;"
Conn.Open
Set AdoCommand = Server.CreateObject("ADODB.Command")
set AdoCommand.ActiveConnection = Conn
Set Recordset = Server.CreateObject("ADODB.RecordSet")
AdoCommand.Properties("Bookmarkable") = True
AdoCommand.CommandText = "select vpath, filename from scope() where contains('Index AND Server')>0"
Recordset.open AdoCommand
SearchString = AdoCommand.Properties("Query Restriction")
%>
<%if SearchString <> "" then%>
<BR>
  <%
  ' Construct the URL for hit highlighting
  WebHitsQuery = "CiWebHitsFile=" & Server.URLEncode( Recordset("vpath") )
  WebHitsQuery = WebHitsQuery & "&CiRestriction=" & Server.URLEncode( SearchString )
  WebHitsQuery = WebHitsQuery & "&CiBeginHilite=" & Server.URLEncode( "<font color=""#FF0000""><b><em>" )
  WebHitsQuery = WebHitsQuery & "&CiEndHilite=" & Server.URLEncode( "</em></b></font>" )
  WebHitsQuery = WebHitsQuery & "&CiUserParam3=" & QueryForm
  %>
  <a href="/iissamples/issamples/Oop/Qsumrhit.htw?<%= WebHitsQuery %>"><b>Show Highlights (condensed)</b></a> /
  <a href="/iissamples/issamples/Oop/Qfullhit.htw?<%= WebHitsQuery %>&CiHiliteType=Full"><b>Show Highlights (full
text)</b></a>
<BR>
<%end if%> 


© 1997 by Microsoft Corporation. All rights reserved.