当前位置: 首页>>代码示例>>Java>>正文


Java IndexNotFoundException类代码示例

本文整理汇总了Java中org.apache.lucene.index.IndexNotFoundException的典型用法代码示例。如果您正苦于以下问题:Java IndexNotFoundException类的具体用法?Java IndexNotFoundException怎么用?Java IndexNotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexNotFoundException类属于org.apache.lucene.index包,在下文中一共展示了IndexNotFoundException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _getReader

import org.apache.lucene.index.IndexNotFoundException; //导入依赖的package包/类
@Nullable
private DirectoryReader _getReader () throws IOException
{
  _checkClosing ();
  try
  {
    // Commit the writer changes only if a reader is requested
    if (m_aWriterChanges.intValue () > 0)
    {
      s_aLogger.info ("Lazily committing " + m_aWriterChanges.intValue () + " changes to the Lucene index");
      _getWriter ().commit ();
      m_aWriterChanges.set (0);
    }

    // Is a new reader required because the index changed?
    final DirectoryReader aNewReader = m_aIndexReader != null ? DirectoryReader.openIfChanged (m_aIndexReader)
                                                              : DirectoryReader.open (m_aDir);
    if (aNewReader != null)
    {
      // Something changed in the index
      m_aIndexReader = aNewReader;
      m_aSearcher = null;

      if (s_aLogger.isDebugEnabled ())
        s_aLogger.debug ("Contents of index changed. Creating new index reader");
    }
    return m_aIndexReader;
  }
  catch (final IndexNotFoundException ex)
  {
    // No such index
    return null;
  }
}
 
开发者ID:phax,项目名称:peppol-directory,代码行数:35,代码来源:PDLucene.java

示例2: getLastCommit

import org.apache.lucene.index.IndexNotFoundException; //导入依赖的package包/类
/**
 * Returns the last {@link IndexCommit} found in the {@link Directory}, or
 * {@code null} if there are no commits.
 */
public static IndexCommit getLastCommit(Directory dir) throws IOException {
  try {
    if (DirectoryReader.indexExists(dir)) {
      List<IndexCommit> commits = DirectoryReader.listCommits(dir);
      // listCommits guarantees that we get at least one commit back, or
      // IndexNotFoundException which we handle below
      return commits.get(commits.size() - 1);
    }
  } catch (IndexNotFoundException e) {
    // ignore the exception and return null
  }
  return null;
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:IndexReplicationHandler.java

示例3: testNoDir

import org.apache.lucene.index.IndexNotFoundException; //导入依赖的package包/类
public void testNoDir() throws Throwable {
  File tempDir = createTempDir("doesnotexist");
  TestUtil.rm(tempDir);
  Directory dir = getDirectory(tempDir);
  try {
    DirectoryReader.open(dir);
    fail("did not hit expected exception");
  } catch (NoSuchDirectoryException | IndexNotFoundException nsde) {
    // expected
  }
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:BaseDirectoryTestCase.java

示例4: openIndexes

import org.apache.lucene.index.IndexNotFoundException; //导入依赖的package包/类
private void openIndexes(boolean overwrite) throws IOException {
  if (directory == null) {
    try {
      if (path == null)
        directory = new RAMDirectory();
      else {
        //directory = new MMapDirectory(new File(config.getPath()));
        // as per http://wiki.apache.org/lucene-java/ImproveSearchingSpeed
        // we use NIOFSDirectory, provided we're not on Windows
        if (Utils.isWindowsOS())
          directory = FSDirectory.open(new File(path));
        else
          directory = NIOFSDirectory.open(new File(path));
      }

      IndexWriterConfig cfg =
        new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
      cfg.setOpenMode(overwrite ? IndexWriterConfig.OpenMode.CREATE :
                                  IndexWriterConfig.OpenMode.APPEND);
      iwriter = new IndexWriter(directory, cfg);
      iwriter.commit(); // so that the searcher doesn't fail
    } catch (IndexNotFoundException e) {
      if (!overwrite) {
        // the index was not there, so make a new one
        directory = null; // ensure we really do try again
        openIndexes(true);
      } else
        throw new DukeException(e);
    }
  }
}
 
开发者ID:larsga,项目名称:Duke,代码行数:32,代码来源:LuceneDatabase.java


注:本文中的org.apache.lucene.index.IndexNotFoundException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。