import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexModifier;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
{
synchronized( repository )
{
- IndexModifier indexModifier = null;
+ IndexWriter indexWriter = null;
try
{
- indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() );
- indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH );
+ indexWriter = new IndexWriter( indexLocation, indexHandlers.getAnalyzer(), !exists() );
+ indexWriter.setMaxFieldLength( MAX_FIELD_LENGTH );
for ( Iterator i = records.iterator(); i.hasNext(); )
{
{
Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
- indexModifier.deleteDocuments( term );
+ indexWriter.deleteDocuments( term );
Document document = indexHandlers.getConverter().convert( record );
- indexModifier.addDocument( document );
+ indexWriter.addDocument( document );
}
}
- indexModifier.optimize();
+ indexWriter.optimize();
}
catch ( IOException e )
{
}
finally
{
- closeQuietly( indexModifier );
+ closeQuietly( indexWriter );
}
}
}
{
synchronized( repository )
{
- IndexModifier indexModifier = null;
+ IndexWriter indexWriter = null;
try
{
- indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() );
- indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH );
+ indexWriter = new IndexWriter( indexLocation, indexHandlers.getAnalyzer(), !exists() );
+ indexWriter.setMaxFieldLength( MAX_FIELD_LENGTH );
if ( record != null )
{
Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
- indexModifier.deleteDocuments( term );
+ indexWriter.deleteDocuments( term );
Document document = indexHandlers.getConverter().convert( record );
- indexModifier.addDocument( document );
+ indexWriter.addDocument( document );
}
- indexModifier.optimize();
+ indexWriter.optimize();
}
catch ( IOException e )
{
}
finally
{
- closeQuietly( indexModifier );
+ closeQuietly( indexWriter );
}
}
}
}
}
- private static void closeQuietly( IndexModifier indexModifier )
- {
- if ( indexModifier != null )
- {
- try
- {
- indexModifier.close();
- }
- catch ( IOException e )
- {
- // ignore
- }
- }
- }
-
private static void closeQuietly( IndexReader reader )
{
try