lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ngo, Anh \(ISS Southfield\)" <a...@iss.net>
Subject IndexWriter.optimize()
Date Tue, 30 May 2006 21:04:50 GMT
Hello All,

I am new to Java Lucene Api.  I am writing a heavy test for lucene java
api. The test is to write text data to disk and also create a lucene
index for it.  Everytime, I write index file, I do the following:

org.apache.lucene.index.IndexWriter writer = new
org.apache.lucene.index.IndexWriter(indexDirectory, new
StandardAnalyzer(), createDb);
        try {
            writer.setMergeFactor(20);
            writer.addDocument(FileDocument.Document(f));
            writer.optimize();
        }
        catch(Exception e)
        {
          throw e;
        }
        Finally()
        {
          writer.close();
        }

Questions:

1/Should I have a IndexWriter stay open or should I open/close it for
every write?

2/
I have the following error when do the optimize() call.  Do I have to
make this call every time I write a file to lucene index?


Thanks for your help

Anh Ngo



[Thread-4] ERROR index - Indexed: Exception: Bad file descriptor
java.io.RandomAccessFile.seek(Native Method)
org.apache.lucene.store.FSIndexInput.readInternal(FSDirectory.java:444)
org.apache.lucene.store.BufferedIndexInput.readBytes(BufferedIndexInput.
java:45)
org.apache.lucene.index.CompoundFileReader$CSIndexInput.readInternal(Com
poundFileReader.java:219)
org.apache.lucene.store.BufferedIndexInput.refill(BufferedIndexInput.jav
a:64)
org.apache.lucene.store.BufferedIndexInput.readByte(BufferedIndexInput.j
ava:33)
org.apache.lucene.store.IndexInput.readVInt(IndexInput.java:56)
org.apache.lucene.index.SegmentTermPositions.nextPosition(SegmentTermPos
itions.java:48)
org.apache.lucene.index.SegmentMerger.appendPostings(SegmentMerger.java:
356)
org.apache.lucene.index.SegmentMerger.mergeTermInfo(SegmentMerger.java:2
98)
org.apache.lucene.index.SegmentMerger.mergeTermInfos(SegmentMerger.java:
272)
org.apache.lucene.index.SegmentMerger.mergeTerms(SegmentMerger.java:236)
org.apache.lucene.index.SegmentMerger.merge(SegmentMerger.java:89)
org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:681)
org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:658)
org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:517) 

-----Original Message-----
From: Doug Cutting [mailto:cutting@apache.org] 
Sent: Tuesday, May 30, 2006 4:54 PM
To: java-dev@lucene.apache.org
Subject: Re: Lucene and Java 1.5

Robert Engels wrote:
> 1.5 has built in Logging support - eliminating the need for Jakarta
logging.

Logging was first added in Java 1.4.

> That is like saying Jarkarta Collections does not use JDK 1.5. No one
that
> develops NEW software uses Jakarta Collections - they use the
Collections
> support in the JDK.

But lots of folks do use log4j in favor of Java's built-in logging. 
Commons Logging permits one to code to a generic logging API and let the

application configuration determine whether that's Java's logging, log4j

or something else.

Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message