Expand News
IS Administration
Expand MMC
Expand Com Objects
Expand IDA/IDQ
IS Programming
Expand IS Programming
IS TroubleShooting
Expand Indexing
Expand Querying
IS Optimizing
Expand Querying
Expand Indexing
IS Links
Expand MSDN
Expand TechNet
Expand Other MS
Expand Other Links
iFilters
Expand iFilters
SQL 2000 FTS
Expand Loading Data
Expand Indexing
Expand Querying
Contains
Freetext
ContainsTable/FreetextTable
ASP
ISAPI
.Net
SQLXML
Thesaurus
Languages
Trouble Shooting
Hit Highlighting
Blobs
Dealing with Noise words
Expand SQL FTS Links
SQL 2005 FTS
Expand What's New

Index Server Faq

Using Indexing Services hit highlighting feature to do hit highlighting in SQL FTS

Indexing Services does not do inline hit highlighting, it requires the user to click on a specially crafted hyperlink which posts the path to the document you wish to hightlihg and the query to an ISAPI extension.

Below is an image of a typical web page implementing hit highlighting.

Notice the two hyperlinks marked Full and Summary. Clicking on these will generate hit highlighted documents as illustrated below:

You can click on the double brackets << or >> to move from one highlighted hit to another.

There are five parts to enabling hit highlighting

  • dump your content row by row into text files in the file system

  • create a virtual directory to this location

  • create hyperlinks to /txt in your database as vpaths (virutal paths). So if you have a row with a pk of 123, you could extract the textual content of this row and store it in the file system with a name like c:\txt\123.txt. Click on this link for sample vbscript to extract your database content and store it in the file system

  • enable the ISAPI extension for webhits.dll

  • craft hyperlinks on your search results page for hit highlighting.


    Let's go over each step in detail.

  • Dump your content in the file system.

    In our case we will be storing it in a directory called c:\txt


    Here is a sample script to do this. We are dumping a table called TextTable.

    Set oFS = CreateObject("Scripting.FileSystemObject")

    Set oConn=CreateObject("ADODB.Connection")

    set oRs=CreateObject("ADODB.Recordset")

    oConn.Open "DRIVER=SQL Server;SERVER= SQLSERVERNAME;UID=sa;PWD=se1cure#;DATABASE=Text;"

    set oRs.ActiveConnection=oConn

    oRs.Open "select pk, TextCol from TextTable"

    do while not oRs.EOF

    set Ts=ofs.CreateTextFile(oRs.Fields(0)& ".txt")

    Ts.WriteLine oRs.Fields(1)

    Ts.Close

    set Ts=nothing

    oRs.MoveNext

    loop

  • Create a virtual directory to this location.

    Here we are making c:\txt a virtual directory called /txt

    Click Start, click run and type %windir%\system32\inetsrv\iis.msc Expand your IIS Server, right click on your web site, point to New and click Virtual Directory.

    At the Welcome to New Virutal Directory dialog box, click Next.

    In the Virtual Directory alias dialog box, enter the alias you wish to use for your virtual directory. In our case we will call it txt. Click Next

    In the Web Site Content Directory dialog box enter the path to where you dumped out your table as text files. We will enter c:\txt. Click Next.

    In the Access Permissions dialog box, enter the permissions you will require for this virutal directory. In our case we only want read access. Clear all other permissions and click Next.

    You will then get a dialog telling you that "You have successfully complete the Virtual Directory Creation Wizard. Click Finish.

  • Create hyperlinks to /txt in your database as vpaths (virutal paths).

    If you have a row with a pk of 123, the vpath would look like /txt/123.txt

    An easy way to do this is issue the following statement in Query Analyzer:

    UPDATE Text Set vpath='/txt/'+PK+'.txt' FROM TEXT

  • Enable the ISAPI extension for webhits.dll

    At a command prompt type md c:\inetpub\wwwroot\oop and press return.

    Open up the IIS MMC again; Click Start, click run and type %windir%\system32\inetsrv\iis.msc Expand your IIS Server, right click on your web site, point to New and click Virtual Directory.

    At the Welcome to Virtual Directory Wizard, click Next.

    Enter oop, which means out of process. Feel free to name this virtual directory any name you want. Click Next.

    In the Web Site Content Directory enter c:\inetpub\wwwroot\oop. Click Next.

    In the Access Permissions dialog box enter Execute. Clear all other options. Click Next.

    Click Finish.

    You now have to enable webhits.dll as the ISAPI extension for htw. All we have done so far is created a virtual directory to hold our template. Right click on your web site in the IIS MMMC and select properties.

    Select the home directory tab.

    Click the Configuration button

    Click add

    For Executable browse to find webhits.dll. This should be in %windir%\system32.

    For Extention type .htw

    For Verbs, select limit to and type GET. Accept all other defaults. Click OK.

  • Craft hyperlinks on your search results page for hit highlighting.

    Hit highlighting has four parameters:

    CiWebHitsfile - a virtual path to the document in the file system you wish to highlight

    CiHiliteType - controls whether you are doing full or summary highlighting

    CiRestriction - the search phrase

    CiDialect - controls whether you are doing a Contains (1) or FreeText query (2). For a Contains based query use 1.

    This example is for ASP.

    WebHitsQuery = "&CiWebHitsFile=" & Server.URLEncode(rtrim(alldata(colcounter+1,iRowLoop))) &"&CiRestriction=" & Server.URLEncode(Search_Phrase)

    Response.Write "<P><ahref=/oop/qhit.htw?CiHiliteType=Summary" & WebHitsQuery & "><IMG src=" &"/hilight.gif" & " align=left alt= " & "Highlight matching terms in document using Summary mode." &"><P>Summary</a><P>"

    Response.Write "<BR>lt;P><P><ahref=/oop/qhit.htw?CiHiliteType= Full" & WebHitsQuery &"><IMG src="& "/hilight.gif"&" align=left alt="&"Highlight matching terms in document."&"><P>Full</a><P>"

    Here is what your template file will look like:

    <HTML>

    <BODY>

    <%BeginDetail%>

    <%EndDetail%>

    </BODY>

    <HTML>

    Place this template file in the /oop virtual directory.

     

     

     

  •  

    designed by :: smilla group