There are many kind of directory types that can be used to build a Lucene index. Which one is best suited to improve search speed on a RedHat machine (not sure if the OS is relevant or not)?
RAMDirectory
- Cannot use, index is too bigSimpleFSDirectory
- Cannot be this one because it's 'Simple'...MMapDirectory
- Maybe this one?NIOFSDirectory
- Or this one?Any better options?
Unless you have a good reason to pick one over the others, I'd recommend simply calling FSDirectory.open(File)
. This allows Lucene to make the decision on which implementation is ideal.
For the curious, here is how the decision is made:
public static FSDirectory open(File path, LockFactory lockFactory) throws IOException {
if ((Constants.WINDOWS || Constants.SUN_OS || Constants.LINUX)
&& Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
return new MMapDirectory(path, lockFactory);
} else if (Constants.WINDOWS) {
return new SimpleFSDirectory(path, lockFactory);
} else {
return new NIOFSDirectory(path, lockFactory);
}
}
If you want to try to be surer about getting the ideal pick than that, I can only recommend trying them and profiling, to see which provides the best performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With