Troubleshooting -- ConvertPath returns a blank string

Article: dts0157

 

Applies to: dtSearch Engine 6 and later

 

After a search, the SearchResults object contains a list of the files that were retrieved. These files are expressed as local paths, such as c:\docs\sample.doc. For web-based applications, it is usually preferable to report document locations using virtual directory names, such as /docs/sample.doc. Also, when highlighting hits in PDF files or creating direct links to retrieved documents, a virtual directory name is required.

To provide a way to map local paths to virtual paths, the dtSearch Engine Server object has a ConvertPath method:

ConvertPath(Path as String, iSite as Long, flags as Long, reserved as String)

     as String

If ConvertPath returns a blank string, it means that either (1) the folder passed in does not have a virtual directory associated with it, (2) the registry tables have not been refreshed since the virtual directory was created, or (3) there is something wrong with the arguments being passed to ConvertPath.

1. Check that the folder has a virtual directory associated with it

Open Internet Services Manager and check the list of virtual directories for the web site. Each web site has its own list of virtual directories, so if you have more than one web site, check that the one you are calling ConvertPath for has the virtual directory definition for the folder.

2. Run dtSearch Web Setup

In dtSearch Desktop, click File > dtSearch Web Setup. When dtSearch Web Setup program opens, close it without doing anything. This will refresh the registry tables that dtSearch uses to store virtual directory information. There is no need to rebuild your indexes after doing this.

3. Stop and restart the W3 service, or reboot the server

Restarting the W3 service will make the ASP application re-read the virtual directory tables from the registry. (You can also call ConvertPath with the dtsCpReadFromRegistry flag to do this.)

In some cases ASP applications are not unloaded even when the W3 service is stopped and restarted.  In these cases, a reboot may be necessary to reload the ASP application.

4. Check the ConvertPath arguments

Path: Check that the path is exactly the same as the virtual directory mapping, or a subdirectory of a virtual directory mapping. Note that mapped network drives cannot be used as virtual directories because Internet Information Server (IIS) and components called from IIS may not see the mapping.

iSite: Check that this matches the web site that has the virtual directory

flags: In ASP, if you use a named constant like dtsCpMakeVirtual, and the constant is not declared in the script or is incorrectly referenced through a type library, ASP will not warn you of the mistake and will instead create a new variable with a value of zero (0). dtsCpMakeVirtual is defined as 1, so try replacing dtsCpMakeVirtual with 1 in your script.

5. Use a debug log to check how dtSearch is handling the call internally

A debug log can help you to check how dtSearch is interpreting the values passed to ConvertPath. For information on debug logging, see:

     Diagnostic tools for Visual Basic and ASP Developers

Additional Information

See the ConvertPath documentation below for more information, or see the "Server" topic in the dtSearch Engine documentation (dtengine.chm).

ConvertPath

Use the Server object's ConvertPath method to convert between virtual and local paths. iSite is the id of the web site on a web server. If there is only one web site on the server, use 1. The ASP value Request.ServerVariables("INSTANCE_ID") can be used if the web server has more than one web site. (The web site id is needed because each site has its own mapping between virtual and local paths.) For the flags value, use dtsCpMakeVirtual to convert from local to virtual paths. Example:      

VirtualPath = Engine.ConvertPath(LocalPath, _ &

     Request.ServerVariables("INSTANCE_ID"), dtsCpMakeVirtual, "")

Internet Information Server stores its mapping between virtual and local paths in the MetaBase. Reading this information from the MetaBase is time-consuming and requires access rights that may not be available to a process running in the web server context. Therefore, the dtSearch Engine caches this information in the registry, under this key:

HKEY_LOCAL_MACHINE\Software\dtSearch Corp.\dtSearch\Virtual Roots

By default, ConvertPath will use the cached table values. Call ConvertPath with the dtsCpRefreshMappings + dtsCpStoreInRegistry flags to update the cached information. Running dtWebSetup.exe, the dtSearch Web Setup program, will also update this information. (You do not have to do anything in dtWebSetup -- just run it and exit to refresh the tables.)