lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jokin Cuadrado" <joki...@gmail.com>
Subject Re: Am I adding docs properly?
Date Thu, 12 Apr 2007 08:47:01 GMT
you can't make 2 write operations at the same time. Only 1 reader or 1
writer can make write operations at the same time on the index, so the
sequence must be:
open reader
    Delete documents
close reader
open writer
    add documents
close writer.

because open the reader an the writer are expensive in cpu and i/o
cost, its better to do in batch operations, removing first all the
modified documents and adding after all the new and modified ones.

>From lucene FAQ:

What is the purpose of write.lock file, when is it used, and by which classes?
The write.lock is used to keep processes from concurrently attempting
to modify an index.

It is obtained by an IndexWriter while it is open, and by an
IndexReader once documents have been deleted and until it is closed.


--
Jokin


On 4/12/07, Max Metral <max@artsalliancelabs.com> wrote:
> Setting the buffer and merge counts seems to break document addition
> somehow.  Here's the "crux" of my Lucene code:
>
>
>
>        IndexWriter writer = indexer.OpenWriter();
>
>        writer.SetMergeFactor(1000);
>
>        writer.SetMaxBufferedDocs(1000);
>
>        while (pageQueue.Count > 0)
>
>        {
>
>               List<Document> ld = indexer.BuildDocuments(page);
>
>               indexer.Remove(page.Id);
>
>               foreach (Document d in ld)
>
>               {
>
>                      indexer.Add(d);
>
>               }
>
>        }
>
>        indexer.CloseWriter();
>
>        // Flush the deletions
>
>        indexer.ReopenReader();
>
>
>
> Remove calls this:
>
>        _Reader.DeleteDocuments(new Term("Id", id.ToString()));
>
> And add calls:
>
>        _Writer.AddDocument(d);
>
>
>
> When I run through this, the remove works but the add does not seem to.
> I built the index initially without a problem, but its these updates
> that seem to be failing.
>
>

Mime
View raw message