File dir = new File(dataDir + "/" + name);
NIOFSDirectory directory = new NIOFSDirectory(dir);
IndexWriter writer;
IndexWriterConfig writerConfig = new IndexWriterConfig(Version.LUCENE_40, analyzer);
LogByteSizeMergePolicy mergePolicy = new LogByteSizeMergePolicy();
mergePolicy.setMaxMergeMB(50.0);
mergePolicy.setUseCompoundFile(true);
mergePolicy.setMergeFactor(8);
writerConfig.setMergePolicy(mergePolicy);
writerConfig.setRAMBufferSizeMB(128.0);
writerConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
writer = new IndexWriter(directory, writerConfig);