Index optimization is yet one of the queued index modification 
tasks like add/remove. We had figured out that optimize is sufficient
if it runs once at startup of our application, not after each and
every index modifiaction.

> -----Original Message-----
> From: Ben Martz [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, January 18, 2007 4:08 PM
> To: lucene-net-user@incubator.apache.org
> Subject: Re: FileNotFoundException, is this code supposed to work?
> 
> I should add further that the only reason I went with a 
> thread for the index
> changes (add/delete/update) is so that I could control the 
> frequency of
> index optimization to keep things running smoothly - I didn't 
> want every
> minor change to result in a blocking optimization call. Other 
> than that, I
> can instantiate multiple copies of my server application and they all
> coexist quite cheerfully using the standard 
> Lucene.Net.lockdir parameter.
> 
> On 1/18/07, Ben Martz <[EMAIL PROTECTED]> wrote:
> >
> > Out of curiosity, are you running into the multiple writer 
> issue when you
> > correctly set up the lock directory? I use the following code in my
> > application prior to creating an index writer.
> >
> >         private static bool m_LockInitted = false;
> >         public static void InitLockDir()
> >         {
> >             if (m_LockInitted)
> >                 return;
> >
> >             string lockPath = Common.GetIndexPath() + @"\lock";
> >
> >             if (!Directory.Exists(lockPath))
> >                 Directory.CreateDirectory(lockPath);
> >
> >             ConfigurationManager.AppSettings["Lucene.Net.lockdir"] =
> > lockPath;    // <-- this is the important part
> >
> >             m_LockInitted = true;
> >         }
> >
> >
> > On 1/18/07, Torsten Rendelmann <[EMAIL PROTECTED]> wrote:
> > >
> > > AFAIK only index modifications require a lock, while a concurrent
> > > search does not. We run into the same problem (concurrent index
> > > writers) and "solved" it using a single index mod. thread working
> > > with a queue of documents to add/delete/update.
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > > > Sent: Monday, January 15, 2007 7:25 PM
> > > > To: lucene-net-user@incubator.apache.org
> > > > Subject: RE: FileNotFoundException, is this code 
> supposed to work?
> > > >
> > > >
> > > > I receive these kinds of errors when multiple threads are
> > > > searching/writing
> > > > to the index at the same time.  So far, I have had to resort
> > > > to .NET locks
> > > > for key locations in code, such as:
> > > >
> > > >       Dim hits As Hits = Nothing
> > > >       SyncLock aLock
> > > >               hits = searcher.Search(query, df1, custSort)
> > > >       End SyncLock
> > > >
> > > >       SyncLock aLock
> > > >               Result = reader.DeleteDocuments(New Term("Id",
> > > > CStr(Id)))
> > > >             reader.Close()
> > > >       End SyncLock
> > > >
> > > >       SyncLock aLock
> > > >               writer.AddDocument(doc)
> > > >               writer.Close()
> > > >       End SyncLock
> > > >
> > > >
> > > > This of course kills our scalability, so I am so interested
> > > > in knowing how
> > > > to address multi-process/multi-threaded access to any
> > > > particular index.
> > > >
> > > >
> > > >
> > > > - Michael
> > > >
> > > >
> > > >
> > > > -----Original Message-----
> > > > From: Simon Gartz [mailto:[EMAIL PROTECTED]
> > > > Sent: Monday, January 15, 2007 6:54 AM
> > > > To: lucene-net-user@incubator.apache.org
> > > > Subject: FileNotFoundException, is this code supposed to work?
> > > >
> > > > Hi,
> > > >
> > > > I've seen this questions before with slightly different
> > > > approaches, but non
> > > > with sample code. Is this code supposed to work or not, using
> > > > Lucene.net
> > > > v1.9.1.3?
> > > > I get follwing error executing the code below. Note that it
> > > > might take some
> > > > time to crash.
> > > >
> > > > System.IO.FileNotFoundException : Could not find file
> > > > "C:\DOCUME~1\sgartz\LOCALS~1\Temp\lucene\_1ji.frq".
> > > >       at System.IO.__Error.WinIOError(Int32 errorCode, 
> String str)
> > > >       at System.IO.FileStream..ctor(String path, FileMode
> > > > mode, FileAccess
> > > > access, FileShare share, Int32 bufferSize, Boolean useAsync,
> > > > String msgPath,
> > > > Boolean bFromProxy)
> > > >       at System.IO.FileStream..ctor(String path, FileMode
> > > > mode, FileAccess
> > > > access, FileShare share)
> > > >       at Lucene.Net.Store.Descriptor..ctor(FSIndexInput
> > > > enclosingInstance, FileInfo file, FileAccess mode)
> > > >       at Lucene.Net.Store.FSIndexInput..ctor(FileInfo path)
> > > >       at Lucene.Net.Store.FSDirectory.OpenInput(String name)
> > > >       at 
> Lucene.Net.Index.SegmentReader.Initialize(SegmentInfo si)
> > > >       at Lucene.Net.Index.SegmentReader.Get(Directory dir,
> > > > SegmentInfo si,
> > > > SegmentInfos sis, Boolean closeDir, Boolean ownDir)
> > > >       at Lucene.Net.Index.SegmentReader.Get(SegmentInfo si)
> > > >       at Lucene.Net.Index.AnonymousClassWith.DoBody ()
> > > >       at Lucene.Net.Store.With.Run()
> > > >       at Lucene.Net.Index.IndexReader.Open(Directory
> > > > directory, Boolean
> > > > closeDirectory)
> > > >       at Lucene.Net.Index.IndexReader.Open(String path)
> > > >       at Lucene.Net.Search.IndexSearcher..ctor(String path)
> > > >
> > > > c:\projects\x\development\x.test\indexingservice\indexingservi
> > > > cetest.cs(
> > > > 128,0): at
> > > > x.Test.IndexingService.IndexingServiceTest.LuceneThreadTest ()
> > > >
> > > >
> > > >   private static readonly string directory =
> > > > Path.Combine(Path.GetTempPath(), "lucene");
> > > >
> > > >   [Test]
> > > >   public void LuceneThreadTest(){
> > > >
> > > >    //Create index
> > > >    Lucene.Net.Analysis.Analyzer analyzer = new
> > > > Lucene.Net.Analysis.SimpleAnalyzer();
> > > >    Lucene.Net.Index.IndexWriter writer = new
> > > > Lucene.Net.Index.IndexWriter(directory, analyzer, true);
> > > >    writer.Close();
> > > >
> > > >    //Start indexing thread
> > > >    Thread indexThread = new Thread(new
> > > > ThreadStart(LuceneIndexThread));
> > > >    indexThread.Start();
> > > >
> > > >    while(indexThread.IsAlive ){
> > > >     Console.WriteLine("Searching...");
> > > >
> > > >     Lucene.Net.Search.Searcher searcher = new
> > > > Lucene.Net.Search.IndexSearcher(directory);
> > > >
> > > >     Lucene.Net.Search.Hits hits = null;
> > > >     Lucene.Net.QueryParsers.QueryParser parser = new
> > > > Lucene.Net.QueryParsers.QueryParser("contents", analyzer);
> > > >     Lucene.Net.Search.Query query = parser.Parse("put");
> > > >     Console.WriteLine("Query: " + query.ToString("contents"));
> > > >
> > > >     hits = searcher.Search(query);
> > > >     Console.WriteLine(hits.Length() + " total results");
> > > >     for (int i = 0; i < hits.Length() && i < 10; i++) {
> > > >      Lucene.Net.Documents.Document d = hits.Doc(i);
> > > >      Console.WriteLine(i + " " + hits.Score(i) + " " +
> > > > d.Get("contents").Length + " " + 
> d.Get("contents").Substring(0, 20));
> > > >     }
> > > >     searcher.Close();
> > > >     Thread.Sleep(1000);
> > > >    }
> > > >   }
> > > >   private void LuceneIndexThread(){
> > > >    Console.WriteLine("Start indexing files");
> > > >    for(int j = 0; j < 100; j++){
> > > >
> > > >     Lucene.Net.Analysis.Analyzer analyzer = new
> > > > Lucene.Net.Analysis.SimpleAnalyzer();
> > > >     Lucene.Net.Index.IndexWriter writer = new
> > > > Lucene.Net.Index.IndexWriter (directory, analyzer, false);
> > > >
> > > >     for (int i = 0; i < 100; i++) {
> > > >      Lucene.Net.Documents.Document d = new
> > > > Lucene.Net.Documents.Document();
> > > >      string content = new string('a', (new 
> Random()).Next(100) * 10);
> > > >      d.Add(new Lucene.Net.Documents.Field("contents", "Put
> > > > contents here " +
> > > > content, Lucene.Net.Documents.Field.Store.YES,
> > > > Lucene.Net.Documents.Field.Index.TOKENIZED));
> > > >      writer.AddDocument(d);
> > > >     }
> > > >     writer.Close();
> > > >     Console.WriteLine("Indexed 100 documents...");
> > > >    }
> > > >    Console.WriteLine("Finished indexing files");
> > > >   }
> > > >
> > > >
> > > > Regards
> > > > Simon
> > > >
> > >
> > >
> > >
> >
> >
> > --
> > Mmmmmm...C8H11NO2
> 
> 
> 
> 
> -- 
> Mmmmmm...C8H11NO2
> 


Reply via email to