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


Java IndexReader.indexExists方法代码示例

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


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

示例1: buildAndRegisterDeltaReader

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
private IndexReader buildAndRegisterDeltaReader(String id) throws IOException
{
    IndexReader reader;
    // only register on write to avoid any locking for transactions that only ever read
    File location = getDeltaLocation(id);
    // File location = ensureDeltaIsRegistered(id);
    // Create a dummy index reader to deal with empty indexes and not
    // persist these.
    if (IndexReader.indexExists(location))
    {
        reader = IndexReader.open(location);
    }
    else
    {
        reader = IndexReader.open(emptyIndex);
    }
    return reader;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:IndexInfo.java

示例2: buildReferenceCountingIndexReader

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
private IndexReader buildReferenceCountingIndexReader(String id, long size) throws IOException
{
    IndexReader reader;
    File location = new File(indexDirectory, id).getCanonicalFile();
    double folderSize = getSizeInMb(location);
    if (IndexReader.indexExists(location))
    {
        if ((size < maxDocsForInMemoryIndex) && (folderSize < maxRamInMbForInMemoryIndex))
        {
            RAMDirectory rd = new RAMDirectory(location);
            reader = IndexReader.open(rd);
        }
        else
        {
            reader = IndexReader.open(location);
        }
    }
    else
    {
        reader = IndexReader.open(emptyIndex);
    }
    reader = ReferenceCountingReadOnlyIndexReaderFactory.createReader(id, reader, true, config);
    return reader;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:IndexInfo.java

示例3: resetClassFields

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
@Override
public void resetClassFields() throws IOException {
    Directory directory = FSDirectory.open(new File(appConfig.getOldAllIndexDir()));
    if (!IndexReader.indexExists(directory)) {
        logger.error("Please reset index firstly!");
        return;
    }
    Directory ram = new RAMDirectory(directory);
    IndexReader preIndexReader = this.indexReader;
    this.indexReader = IndexReader.open(ram);
    logger.info("IndexReader has numDos: {}", this.indexReader.numDocs());

    IndexSearcher preIndexSearcher = this.indexSearcher;
    this.indexSearcher = new IndexSearcher(indexReader);
    IOUtils.closeQuietly(preIndexSearcher, preIndexReader);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:17,代码来源:SearchServiceImpl.java

示例4: reset

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
@PostConstruct
public void reset() {
    final String dirPath = appConfig.getAllQuickTipsIndexDir();
    try {
        Directory directory = FSDirectory.open(new File(dirPath));
        if (!IndexReader.indexExists(directory)) {
            logger.error("Please reset index firstly! The path: {}", dirPath);
            return;
        }
        Directory ram = new RAMDirectory(directory);
        if (this.indexReader == null) {
            reopenIndexSearcher(ram);
        } else {
            logger.info("QuickTips' new indexReader!");
            final IndexReader preIndexReader = this.indexReader;
            final IndexSearcher preIndexSearcher = this.indexSearcher;
            reopenIndexSearcher(ram);
            IOUtils.closeQuietly(preIndexSearcher, preIndexReader);
            logger.info("Reload QuickTips' index!");
        }
        logger.info("QuickTips' IndexReader has numDos: {}", this.indexReader.numDocs());
    } catch (Exception e) {
        logger.error("Exception", e);
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:26,代码来源:QuickTipsService1Impl.java

示例5: reset

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
@PostConstruct
public void reset() {
    String indexDir = appConfig.getAllSpellCheckerDir();
    try {
        Directory spellcheckDir = FSDirectory.open(new File(indexDir));
        if (!IndexReader.indexExists(spellcheckDir)) {
            logger.info("Please reset index firstly!");
            return;
        }
        SpellChecker newSpellChecker = new SpellChecker(spellcheckDir);
        newSpellChecker.setStringDistance(new JaroWinklerDistance());
        newSpellChecker.setAccuracy(0.7f);
        if (spellChecker == null) {
            spellChecker = newSpellChecker;
        } else {
            final Closeable preSpellChecker = spellChecker;
            spellChecker = newSpellChecker;
            IOUtils.closeQuietly(preSpellChecker);
        }
    } catch (Exception e) {
        logger.error("Exception", e);
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:24,代码来源:SpellCheckerServiceImpl.java

示例6: reset

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
@PostConstruct
public void reset() {
    final String dirPath = appConfig.getAllIndexDir();
    try {
        Directory directory = FSDirectory.open(new File(dirPath));
        if (!IndexReader.indexExists(directory)) {
            logger.error("Please reset index firstly! The path: {}", dirPath);
            return;
        }
        Directory ram = new RAMDirectory(directory);
        if (this.indexReader == null) {
            reopenIndexSearcher(ram);
        } else {
            // changed
            logger.info("Search's new indexReader!");
            final IndexReader preIndexReader = this.indexReader;
            final IndexSearcher preIndexSearcher = this.indexSearcher;
            reopenIndexSearcher(ram);
            IOUtils.closeQuietly(preIndexSearcher, preIndexReader);
            logger.info("Reload search index!");
        }
        logger.info("Search's IndexReader has numDos: {}", this.indexReader.numDocs());
    } catch (Exception e) {
        logger.error("Exception", e);
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:27,代码来源:SearchService1Impl.java

示例7: resetQuickTips

import org.apache.lucene.index.IndexReader; //导入方法依赖的package包/类
private void resetQuickTips() throws IOException {
    String indexDir = appConfig.getOldAllQuickTipsIndex();
    Directory directory = FSDirectory.open(new File(indexDir));
    if (!IndexReader.indexExists(directory)) {
        logger.info("Please reset index firstly!");
        return;
    }
    Directory ram = new RAMDirectory(directory);
    this.quickTipsIndexReader = IndexReader.open(ram);
    logger.info("IndexReader has numDos: {}", this.quickTipsIndexReader.numDocs());

    IndexSearcher preIndexSearcher = this.quickTipsSearcher;
    this.quickTipsSearcher = new IndexSearcher(quickTipsIndexReader);
    IOUtils.closeQuietly(preIndexSearcher);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:16,代码来源:QuickTipsServiceImpl.java


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