當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectoryReader.indexExists方法代碼示例

本文整理匯總了Java中org.apache.lucene.index.DirectoryReader.indexExists方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryReader.indexExists方法的具體用法?Java DirectoryReader.indexExists怎麽用?Java DirectoryReader.indexExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.lucene.index.DirectoryReader的用法示例。


在下文中一共展示了DirectoryReader.indexExists方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isIndexed

import org.apache.lucene.index.DirectoryReader; //導入方法依賴的package包/類
@Override
public boolean isIndexed(Project project, ObjectId commit) {
	File indexDir = storageManager.getProjectIndexDir(project.getForkRoot().getId());
	try (Directory directory = FSDirectory.open(indexDir)) {
		if (DirectoryReader.indexExists(directory)) {
			try (IndexReader reader = DirectoryReader.open(directory)) {
				IndexSearcher searcher = new IndexSearcher(reader);
				return getCurrentCommitIndexVersion().equals(getCommitIndexVersion(searcher, commit));
			}
		} else {
			return false;
		}
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:17,代碼來源:DefaultIndexManager.java

示例2: getLoaded

import org.apache.lucene.index.DirectoryReader; //導入方法依賴的package包/類
@Override
public List<RepositoryInfo> getLoaded(final List<RepositoryInfo> repos) {
    final List<RepositoryInfo> toRet = new ArrayList<RepositoryInfo>(repos.size());
    for (final RepositoryInfo repo : repos) {
        File loc = new File(getDefaultIndexLocation(), repo.getId()); // index folder
        try {
            if (loc.exists() && new File(loc, "timestamp").exists() && DirectoryReader.indexExists(new SimpleFSDirectory(loc.toPath()))) {
                toRet.add(repo);
            }
        } catch (IOException ex) {
            LOGGER.log(Level.FINER, "Index Not Available: " +repo.getId() + " at: " + loc.getAbsolutePath(), ex);
        }
    }
    return toRet;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:NexusRepositoryIndexerImpl.java

示例3: indexExists

import org.apache.lucene.index.DirectoryReader; //導入方法依賴的package包/類
public boolean indexExists () {
	try {
		Directory index = FSDirectory.open (Paths.get(indexDirectoryPath));
		return DirectoryReader.indexExists(index);			
	}
	catch (Exception e) {
		throw new RuntimeException ("could not load event index", e);
	}
}
 
開發者ID:ser316asu,項目名稱:Reinickendorf_SER316,代碼行數:10,代碼來源:NoteIndexer.java

示例4: indexExists

import org.apache.lucene.index.DirectoryReader; //導入方法依賴的package包/類
public static final boolean indexExists(final Directory directory) throws IOException {
    return DirectoryReader.indexExists(directory);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:Lucene.java

示例5: addOrUpdateNote

import org.apache.lucene.index.DirectoryReader; //導入方法依賴的package包/類
public void addOrUpdateNote (Note note, String noteHtmlContents) throws IOException {
	Directory index = FSDirectory.open (Paths.get(indexDirectoryPath));
	
	PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper (new StandardAnalyzer (), fieldAnalyzerLookup);
	
	IndexWriterConfig indexWriterConfig = new IndexWriterConfig (analyzer);
	
	indexWriterConfig.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
	
	IndexWriter indexWriter = new IndexWriter (index, indexWriterConfig);
	
	Document d = noteToDocument(note, noteHtmlContents);	
	
	if (!DirectoryReader.indexExists(index)) 
		indexWriter.addDocument(d);
	else {		
		IndexReader indexReader = DirectoryReader.open (index);
		
		IndexSearcher indexSearcher = new IndexSearcher (indexReader);
		
		TopDocs existingDocuments = indexSearcher.search(new TermQuery (new Term ("id", note.getId())), 1);
		
		if (existingDocuments.totalHits == 0)		
			indexWriter.addDocument(d);
		else indexWriter.updateDocument(new Term ("id", note.getId()), d);
	}

	indexWriter.commit();
	
	indexWriter.close();
	
	index.close ();
}
 
開發者ID:ser316asu,項目名稱:Reinickendorf_SER316,代碼行數:34,代碼來源:NoteIndexer.java


注:本文中的org.apache.lucene.index.DirectoryReader.indexExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。