These codes are written in C#,. There is a C# version of Lucene 1.9, which
can be downloaded from http://www.dotlucene.net
This implements the indexing .
     public void CreateIndex()
       {
           try
           {
               AddDirectory(directory);
               writer.Optimize();
               writer.Close();
               directory.Refresh();
           }
           catch (Exception e)
           {
               fmLog.AddLog(fmLog.LogType.Error, Current.User.ID, e.Message
);
               return;
           }
       }

This is a wrapper of IndexSearcher. At first , I want to use a singleton
IndexSearcher. But then I found the updated document can't be retrieved
immediately. So Every time I instantiate a new IndexSeacher, although it is
inefficient.
   public class SingletonSearcher
   {
       SingletonSearcher searcher
       IndexSearcher indexSearcher = null;
       static Object o = typeof(SingletonSearcher);


       /// <summary>
       ///
       /// </summary>
       /// <returns></returns>

       private SingletonSearcher(String indexPath)
       {
           try
           {
               indexSearcher = new IndexSearcher(indexPath);
           }
           catch (Exception e)
           {
               Console.WriteLine(e.Message);
               searcher = null;
           }
       }
       public static SingletonSearcher GetSearcher()
       {
           //lock (o)
           //{
           //    if (searcher == null)
           //       searcher = new SingletonSearcher(Current.Server.Path);
           //    return searcher;
           //}
           return new SingletonSearcher(Current.Server.Path);
       }

       public static Hits GetHits(Query query)
       {
           if (GetSearcher() == null)
               return null;
           else if (GetSearcher().indexSearcher == null)
               return null;
           return GetSearcher().indexSearcher.Search(query);
       }
}

2006/7/28, Doron Cohen <[EMAIL PROTECTED]>:

> Yes, I have closed IndexWriter.  But it doesn't work.

This is strange...
Can you post a small version of your code that can be executed to show the
problem?
- Doron


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to