• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IndexNotFoundException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Property类代码示例发布时间:2022-05-22
下一篇:
Java PackageNamesScanner类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap