本文整理匯總了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);
}
}
示例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;
}
示例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);
}
}
示例4: indexExists
import org.apache.lucene.index.DirectoryReader; //導入方法依賴的package包/類
public static final boolean indexExists(final Directory directory) throws IOException {
return DirectoryReader.indexExists(directory);
}
示例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 ();
}