use of org.apache.lucene.codecs.lucene62.Lucene62Codec in project Anserini by castorini.
the class IndexTopics method run.
private void run() throws IOException, InterruptedException {
final long start = System.nanoTime();
LOG.info("Starting indexer...");
final Directory dir = FSDirectory.open(indexPath);
final SimpleAnalyzer analyzer = new SimpleAnalyzer();
final IndexWriterConfig config = new IndexWriterConfig(analyzer);
config.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
config.setCodec(new Lucene62Codec(Lucene50StoredFieldsFormat.Mode.BEST_SPEED));
config.setUseCompoundFile(false);
final IndexWriter writer = new IndexWriter(dir, config);
index(writer, collectionPath);
int numIndexed = writer.maxDoc();
try {
writer.commit();
} finally {
try {
writer.close();
} catch (IOException e) {
LOG.error(e);
}
}
LOG.info("Indexed documents: " + counters.indexedDocuments.get());
final long durationMillis = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS);
LOG.info("Total " + numIndexed + " documents indexed in " + DurationFormatUtils.formatDuration(durationMillis, "HH:mm:ss"));
}
use of org.apache.lucene.codecs.lucene62.Lucene62Codec in project Anserini by castorini.
the class IndexObjectTriples method run.
private void run() throws IOException, InterruptedException {
final long start = System.nanoTime();
LOG.info("Starting indexer...");
final Directory dir = FSDirectory.open(indexPath);
final EnglishAnalyzer analyzer = new EnglishAnalyzer();
final IndexWriterConfig config = new IndexWriterConfig(analyzer);
config.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
config.setCodec(new Lucene62Codec(Lucene50StoredFieldsFormat.Mode.BEST_SPEED));
config.setUseCompoundFile(false);
final IndexWriter writer = new IndexWriter(dir, config);
index(writer, collectionPath);
int numIndexed = writer.maxDoc();
try {
writer.commit();
} finally {
try {
writer.close();
} catch (IOException e) {
LOG.error(e);
}
}
LOG.info("Indexed documents: " + counters.indexedDocuments.get());
final long durationMillis = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start, TimeUnit.NANOSECONDS);
LOG.info("Total " + numIndexed + " documents indexed in " + DurationFormatUtils.formatDuration(durationMillis, "HH:mm:ss"));
}
Aggregations