use of org.apache.lucene.search.Similarity in project neo4j-mobile-android by neo4j-contrib.
the class LuceneDataSource method getIndexWriter.
synchronized IndexWriter getIndexWriter(IndexIdentifier identifier) {
if (closed)
throw new IllegalStateException("Index has been shut down");
Pair<IndexWriter, AtomicBoolean> writer = indexWriters.get(identifier);
if (writer != null) {
return writer.first();
}
try {
Directory dir = getDirectory(baseStorePath, identifier);
directoryExists(dir);
IndexType type = getType(identifier);
IndexWriterConfig writerConfig = new IndexWriterConfig(LUCENE_VERSION, type.analyzer);
writerConfig.setIndexDeletionPolicy(new MultipleBackupDeletionPolicy());
Similarity similarity = type.getSimilarity();
if (similarity != null) {
writerConfig.setSimilarity(similarity);
}
IndexWriter indexWriter = new IndexWriter(dir, writerConfig);
writer = Pair.of(indexWriter, new AtomicBoolean());
// TODO We should tamper with this value and see how it affects the
// general performance. Lucene docs says rather <10 for mixed
// reads/writes
// writer.setMergeFactor( 8 );
indexWriters.put(identifier, writer);
return writer.first();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations