當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。