/**
 * 
 */
package eu.dnetlib.data.collective.manager.log;

import java.io.File;
import java.io.IOException;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.Version;

/**
 * @author js
 *
 */
public class AbstractIndexWriter {
	protected IndexWriter indexWriter;

	/**
	 * @param indexDirectory
	 * @param create
	 * @throws CorruptIndexException
	 * @throws LockObtainFailedException
	 * @throws IOException
	 */
	public void init(File indexDirectory, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException{		

		indexWriter = new IndexWriter(
				FSDirectory.open(indexDirectory), new StandardAnalyzer(Version.LUCENE_CURRENT), create, IndexWriter.MaxFieldLength.UNLIMITED);
		indexWriter.verbose();
	}

}
