public static IndexWriter openWriter(Directory directory, int maxMergeDocs, boolean useSerialMerger) throws CorruptIndexException, LockObtainFailedException, IOException {
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(LUCENE_VERSION, analyzer);
if (useSerialMerger) {
indexWriterConfig.setMergeScheduler(mergeScheduler);
}
LogMergePolicy mergePolicy = new LogByteSizeMergePolicy();
mergePolicy.setMaxMergeDocs(maxMergeDocs);
mergePolicy.setUseCompoundFile(false);
indexWriterConfig.setMergePolicy(mergePolicy);
return new IndexWriter(directory, indexWriterConfig);
}