Skip to main content.
home | support | download

Back to List Archive

Re: [swish-e] Re: Proximity for Swish-e/SwishCtl

From: Herman Knoops <hk.sw(at)>
Date: Fri Feb 01 2008 - 11:18:54 GMT

See small example at the end. It should give an
idea how easy it is to work with Swish-e in a
Windows environment.

Herman Knoops
KnoMan b.v.
The Netherlands

> So, If I register swishctl.dll on the iis server, I should then be
> able to instantiate it directly from .asp using:
> Set swishctl = Server.CreateObject("SwishCtl.CSwishCtl")

> I read that the index location needs to be set in the server registry.
> But I assume that I can specify the index files from .asp using:
> swishctl.Init("index1.idx")
If you use our SwishCtl.DLL you can overrule the registry
mechanism, so you're more flexible if you have multiple
document sets/sites (see special pattern below "@@KM@@").

> strResult = swishctl.Execute("test")
> response.write strResult
Not correct, see how to get the results, below.

<% Response.Buffer = True
  Dim sSearchPhrase
  Dim lRes
  Dim lHits
  Dim sIDXFolder
  Dim oSW

  sSearchPhrase = "test"

  On Error Resume Next  ' Don't do this in production (handle each error)
  Set oSW = CreateObject("SwishCtl.CSwishCtl")
  If IsObject(oSW) = False Then
    Response.Write("ERROR: SwishCtl.DLL not correctly registered?")
    Response.AppendToLog ("ERROR: Create object SwishCtl.CSwishCtl")
    sIDXFolder = "d:/sw-idx/idx001"    ' This can be set dynamically
    oSW.Init "@@KM@@" & sIDXFolder & "+docs.idx"

    oSW.Execute sSearchPhrase
    lHits = oSW.Hits

    ' Output to user
    Response.Write "<html><body><h1>"
    Response.Write "Search prhase: " + sSearchPhrase + "<br>"
    Response.Write "# of Hits: " + CStr(lHits) + "<br>"
    Response.Write "</h1>"

    ' Show path of first hit
    If (lHits > 0) And (oSw.Error = 0) Then
      Response.Write "</h3>"
      oSW.SeekResult 0
      Response.Write "Path 001: " + oSW.ResultPropertyString("swishdocpath")
+ "<br>"
      Response.Write "<h3>"
    End If

    Response.Write "</body></html>"

  End If

  If IsObject(oSW) = True Then
    Response.Write "Cleanup"
    oSW.Close ' Make sure to close Swish-e always
    Set oSW = Nothing
  End If

Users mailing list
Received on Fri Feb 1 06:18:56 2008