* @param directory the Directory to initialize
* @throws SearchException in case of lock acquisition timeouts, IOException, or if a corrupt index is found
*/
public static void initializeIndexIfNeeded(Directory directory) {
//version doesn't really matter as we won't use the Analyzer
Version version = Environment.DEFAULT_LUCENE_MATCH_VERSION;
SimpleAnalyzer analyzer = new SimpleAnalyzer( version );
try {
if ( ! IndexReader.indexExists( directory ) ) {
IndexWriterConfig iwriterConfig = new IndexWriterConfig( version, analyzer ).setOpenMode( OpenMode.CREATE );
IndexWriter iw = new IndexWriter( directory, iwriterConfig );