Reputation: 1021
I have this simple Lucene code:
Directory dir = FSDirectory.open(Paths.get("C:/temp/Lucene"));
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
writer = new IndexWriter(dir, iwc);
How can I use Exodus Directory in Java instead of the FSDirectory
?
Upvotes: 0
Views: 67
Reputation: 2053
ExodusDirectory
should be used atop of ContextualEnvironment
:
ContextualEnvironment env = Environments.newContextualInstance(..);
ExodusDirectory dir = new ExodusDirectory(env, VfsConfig.DEFAULT, StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING, new ExodusDirectoryConfig());
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE);
writer = env.computeInTransaction(txn -> {
try {
return new IndexWriter(dir, iwc);
} catch (IOException e) {
return null;
}
});
Configuration parameters of ExodusDirectory can tuned, but StoreConfig.WITHOUT_DUPLICATES_WITH_PREFIXING
is preferable for using.
Upvotes: 2