Indexing catalog doesn’t return aliased path if single directory is added to scope.

I have an Indexing catalog on the FileServer with several directories specified with local path and UNC aliases(e.g.

physical path C:DataSamplesIndexingTestFolder with \vKnowledgeIndexingTestFolder  alias)

I also have .Net application that queries this indexing catalog using IXSSO Control Library -Indexing services((See my post how to use Fill Dataset with rows in a specified range  http://thespoke.net/blogs/mnf/archive/2005/05/09/92495.aspx).
Results returned include Path column which is expected to be formatted using alias, e.g.  
\vKnowledgeIndexingTestFolderSampleFile.txt
It works fine if I don’t call Utility.AddScopeToQuery.
However it returns local path (e.g. C:DataSamplesIndexingTestFolderSampleFile.txt)  , if a single directory is added with AddScopeToQuery.

The behavior is the same for Windows 2000 and 2003 servers.(I haven’t tried Vista yet). 

Interesting enough, if you add more than one dirctory  via call AddScopeToQuery, the path column returned correct UNC path with alias prefix.

The workaround is quite simple (after  I figured out, how it works). If there is only one directory in the scope, add extra dummy directory.

Below is the test case that I’ve used to investigate the problem:

using System.Collections;

using System.Collections.Specialized;

using System.IO;

//’Refer from http://www.webservertalk.com/message309144.html

using Cisso; // COM REF ixsso Control Library (Indexing services)

using ADODB; // COM REF Microsoft ActiveX Data Objects 2.7 Library C:Program FilesMicrosoft.NETPrimary Interop Assembliesadodb.dll

 

        public void CallVKnowledgeRemoteCatalogWithDirectoriesSpecified()

        {

            string CatalogName;

            string[] aScopeDirectories;

            CatalogName = “query://vKnowledge/LocalManyFiles”;

            aScopeDirectories = new string[] { @”C:DataSamplesIndexingTestFolder” };

            QueryWithScope(CatalogName, aScopeDirectories);

            aScopeDirectories = new string[] { @”C:DataSamplesIndexingTestFolder”,@”C:XXX” };

            QueryWithScope(CatalogName, aScopeDirectories);

            aScopeDirectories = new string[] { @”C:DataSamplesIndexingManyFilesTest” };

            QueryWithScope(CatalogName, aScopeDirectories);

            aScopeDirectories = new string[] { };

            QueryWithScope(CatalogName, aScopeDirectories);

            aScopeDirectories = new string[] { @”C:DataSamplesIndexingManyFilesTest”, @”C:DataSamplesIndexingTestFolder” };

            QueryWithScope(CatalogName, aScopeDirectories);

        }

 

        private static void QueryWithScope(string CatalogName, string[] aScopeDirectories)

        {

            DateTime timeStart = DateTime.Now;//to report timeout errors

            //from http://groups.google.com.au/group/microsoft.public.dotnet.languages.csharp/msg/0f1f669443401cf4?hl=en

            CissoQueryClass query = new CissoQueryClass();

            CissoUtilClass util = new CissoUtilClass();

            ADODB.Recordset rs = null;

            try

            {

                query.Query = @”not #vpath = *_vti_* and not #filename *.config AND {prop name=all} “”Library”” {/prop}”;//qb.Query;

                query.Catalog = CatalogName;

                query.SortBy = “Rank [d]”;//qb.SortBy;

                query.Columns = “Rank, VPath, DocTitle, Filename, Characterization, Write, Path ,ClassId, DocAppName”;//qb.Columns;

                foreach (string sDir in aScopeDirectories)

                {

                    util.AddScopeToQuery(query, sDir, “deep”);

                }

                GetAndPrintRecordset(query, ref rs,10);

                Trace.WriteLine(TraceHelper.TracedTimeSpanAsString(timeStart, ” IXSSO timespan = “));

            }

            finally

            {   //19/9/2005 recommended by http://www.eggheadcafe.com/forumarchives/inetserverindexserver/Aug2005/post23479438.asp

                if (rs != null) Marshal.ReleaseComObject(rs); //Recordset 

                if (query != null) Marshal.ReleaseComObject(query); //Query 

                if (util != null) Marshal.ReleaseComObject(util); //Utils 

                query = null;

                util = null;

                rs = null;

            }

        }

 

        private static void GetAndPrintRecordset(CissoQueryClass query, ref ADODB.Recordset rs, int MaxRecordsToPrint)

        {

            rs = (ADODB.Recordset)query.CreateRecordset(“nonsequential”);

            Trace.WriteLine(“rs rows=” + rs.RecordCount);

            int i = 0;

            while (!rs.EOF)

            {

                DebugHelper.PrintCurrentRow(rs, “”);

                rs.MoveNext();

                if (i++ > MaxRecordsToPrint) break;

            }

         //   Trace.WriteLine(TraceHelper.TracedTimeSpanAsString(timeStart, ” return recordset “));

        }//GetPageDataSet

 

And the code for workaround:

        //There is a IXSSO bug: when adding single Scope, returned  PATH has C: format, rather than UNC format

        void FixScopeDirectories(string CatalogName, string[] ScopeDirectories )

        {  //may be check that VPATH is empty should be done

            if(CatalogName.ToLower().StartsWith(“query://”))

            {

                if (ScopeDirectories.Length == 1)

                {

                    List<String> lstArray = new List<string>(ScopeDirectories);

                    lstArray.Add(@”C:NotExistingFolder”);

                     ScopeDirectories = lstArray.ToArray();

                }

            }

        }