本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}