10

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 big
  • SimpleFSDirectory - Cannot be this one because it's 'Simple'...
  • MMapDirectory - Maybe this one?
  • NIOFSDirectory - Or this one?
  • Any better options?
4

1 回答 1

11

除非您有充分的理由选择其中之一,否则我建议您直接调用FSDirectory.open(File). 这允许 Lucene 决定哪种实现是理想的。

对于好奇的人,这里是如何做出决定的:

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);
  }
}

如果您想更确定地获得理想的选择,我只能建议尝试它们并进行分析,看看哪个提供了最佳性能。

于 2013-09-23T23:44:09.350 回答