IndexWriter writer = null;
try {
Directory directory = FSDirectory.open( new File( luceneDir ) );
IndexWriterConfig config = new IndexWriterConfig( Version.LUCENE_CURRENT, new WhitespaceAnalyzer( Version.LUCENE_CURRENT ) );
/*
IndexWriterConfig.OpenMode.CREATE_OR_APPEND if used IndexWriter will create a new index if there is not
already an index at the provided path and otherwise open the existing index.
*/
config.setOpenMode( IndexWriterConfig.OpenMode.CREATE_OR_APPEND );
writer = new IndexWriter( directory, config );
} catch ( IOException e ) {
Logger.error( this, e.getMessage(), e );
}