本文整理汇总了Java中org.apache.lucene.search.SearcherManager.acquire方法的典型用法代码示例。如果您正苦于以下问题:Java SearcherManager.acquire方法的具体用法?Java SearcherManager.acquire怎么用?Java SearcherManager.acquire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.SearcherManager
的用法示例。
在下文中一共展示了SearcherManager.acquire方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readLastCommittedSegmentInfos
import org.apache.lucene.search.SearcherManager; //导入方法依赖的package包/类
/**
* Read the last segments info from the commit pointed to by the searcher manager
*/
protected static SegmentInfos readLastCommittedSegmentInfos(final SearcherManager sm, final Store store) throws IOException {
IndexSearcher searcher = sm.acquire();
try {
IndexCommit latestCommit = ((DirectoryReader) searcher.getIndexReader()).getIndexCommit();
return Lucene.readSegmentInfos(latestCommit);
} catch (IOException e) {
// Fall back to reading from the store if reading from the commit fails
try {
return store.readLastCommittedSegmentsInfo();
} catch (IOException e2) {
e2.addSuppressed(e);
throw e2;
}
} finally {
sm.release(searcher);
}
}
示例2: readLastCommittedSegmentInfos
import org.apache.lucene.search.SearcherManager; //导入方法依赖的package包/类
/**
* Read the last segments info from the commit pointed to by the searcher manager
*/
protected static SegmentInfos readLastCommittedSegmentInfos(final SearcherManager sm, final Store store) throws IOException {
IndexSearcher searcher = sm.acquire();
try {
IndexCommit latestCommit = ((DirectoryReader) searcher.getIndexReader()).getIndexCommit();
return Lucene.readSegmentInfos(latestCommit);
} catch (IOException e) {
// Fall back to reading from the store if reading from the commit fails
try {
return store. readLastCommittedSegmentsInfo();
} catch (IOException e2) {
e2.addSuppressed(e);
throw e2;
}
} finally {
sm.release(searcher);
}
}
示例3: findWave
import org.apache.lucene.search.SearcherManager; //导入方法依赖的package包/类
@Override
public Digest findWave(WaveId waveId, ParticipantId viewer) {
TermQuery query = new TermQuery(new Term(IndexCondition.Field.WAVE_ID.toString(), waveId.serialise()));
SearcherManager searcherManager = nrtManager.getSearcherManager(true);
IndexSearcher indexSearcher = searcherManager.acquire();
try {
TopDocs hints = indexSearcher.search(query, 1);
if (hints.totalHits != 0) {
ScoreDoc hint = hints.scoreDocs[0];
return parseDigest(indexSearcher.doc(hint.doc), null);
}
} catch (IOException ex) {
LOG.log(Level.SEVERE, "Search wave " + waveId.serialise() + " failed", ex);
}
return null;
}
示例4: FullTextCursor
import org.apache.lucene.search.SearcherManager; //导入方法依赖的package包/类
public FullTextCursor(QueryContext context, HKeyRowType rowType,
SearcherManager searcherManager, Query query, int limit) {
this.context = context;
this.rowType = rowType;
this.searcherManager = searcherManager;
this.query = query;
this.limit = limit;
//adapter = context.getStore();
searcher = searcherManager.acquire();
}
示例5: LuceneKVSIterator
import org.apache.lucene.search.SearcherManager; //导入方法依赖的package包/类
/**
* constructor
* @param manager lucene searcher manager
* @param parent parent map
* @throws IOException IOException
*/
public LuceneKVSIterator(SearcherManager manager, LuceneKVSBase<K, V> parent) throws IOException {
this.manager = manager;
this.parent = parent;
manager.maybeRefreshBlocking();
searcher = manager.acquire();
reader = searcher.getIndexReader();
maxDoc = reader.maxDoc();
size = reader.numDocs();
docCount = 0;
entryCount = 0;
}
示例6: testSearcherManager
import org.apache.lucene.search.SearcherManager; //导入方法依赖的package包/类
@Test
public void testSearcherManager() throws IOException {
SearcherManager searcherManager = new SearcherManager(indexWriter.getDirectory(), new SearcherFactory());
IndexSearcher indexSearcher = null;
try {
indexSearcher = searcherManager.acquire();
}
finally {
if (indexSearcher == null) {
searcherManager.release(indexSearcher);
}
}
}