本文整理匯總了Java中org.apache.lucene.search.TopDocs.merge方法的典型用法代碼示例。如果您正苦於以下問題:Java TopDocs.merge方法的具體用法?Java TopDocs.merge怎麽用?Java TopDocs.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.lucene.search.TopDocs
的用法示例。
在下文中一共展示了TopDocs.merge方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTopShardDocs
import org.apache.lucene.search.TopDocs; //導入方法依賴的package包/類
private ScoreDoc[] getTopShardDocs(AtomicArray<QuerySearchResultProvider> results) throws IOException {
List<AtomicArray.Entry<QuerySearchResultProvider>> resultList = results.asList();
TopDocs[] shardTopDocs = new TopDocs[resultList.size()];
for (int i = 0; i < resultList.size(); i++) {
shardTopDocs[i] = resultList.get(i).value.queryResult().topDocs();
}
int topN = Math.min(results.get(0).queryResult().size(), getTotalQueryHits(results));
return TopDocs.merge(topN, shardTopDocs).scoreDocs;
}
示例2: getSearchTotalhitsByOriginalPhrase
import org.apache.lucene.search.TopDocs; //導入方法依賴的package包/類
private TopDocs getSearchTotalhitsByOriginalPhrase(String q, String[] qs, Boolean bNoAds, Boolean bOfficial)
throws Exception, IOException {
// avoid the dead loop
final Keyword manualKeyword = keywordService.getByName(q);
SearchRankType searchRankType = null;
String[] targetQs = null;
if (manualKeyword == null) {
// TODO 最好做qq過濾
if (q.matches(qqSearchRegex)) {
} else if (qs.length < 2) {
targetQs = new String[] { q };
} else {
return getSearchTotalhitsByMultiplyPhrase(q, qs, bNoAds, bOfficial);
}
} else if (manualKeyword.getTargetKeyword() != null) {
if (!manualKeyword.getTargetKeyword().isEmpty()) {
targetQs = manualKeyword.getTargetKeyword().split(",");
} else {
}
searchRankType = SearchRankType.valueOf(manualKeyword.getRankType().toUpperCase());
}
// 根據搜索的特點,熱門和長度做處理
if (searchRankType == null) {
if (q.matches(qqSearchRegex)) {
searchRankType = SearchRankType.ONLY_NAME_DOWNLOAD;
q = "qq";
} else {
// TODO 看需求. 百度是有查詢其它字段的.並做分詞搜索.
// if (q.length() > 3) {
// // searchRankType = SearchRankType.DOCUMENT;
// searchRankType = SearchRankType.ONLY_NAME_DOWNLOAD;
// } else if (q.length() == 3) {
// // searchRankType = SearchRankType.ONLY_NAME_DOCUMENT;
// searchRankType = SearchRankType.ONLY_NAME_DOWNLOAD;
// } else if (q.length() == 2) {
// // 不對搜索詞進行分詞分析的匹配.
// searchRankType = SearchRankType.ONLY_NAME_DOWNLOAD;
if (q.length() > 1) {
searchRankType = SearchRankType.ONLY_NAME_DOWNLOAD;
} else {
searchRankType = SearchRankType.DOWNLOAD;
}
}
}
if (targetQs == null) {
return getSearchTotalhitsBySinglePhrase(q, searchRankType, bNoAds, bOfficial);
// TODO 不適合現在做.
// if (docs.totalHits < 1 && q.length() > 3) {
// searchRankType = SearchRankType.DOWNLOAD;
// return getSearchTotalhitsBySinglePhrase(q, searchRankType,
// catalog, bNoAds, bOfficial);
// }
} else if (targetQs.length <= 1) {
return getSearchTotalhitsBySinglePhrase(targetQs[0], searchRankType, bNoAds, bOfficial);
}
// has munual search words , multi phrases
final TopDocs[] topDocsArray = new TopDocs[targetQs.length];
for (int i = 0; i < targetQs.length; i++) {
topDocsArray[i] = getSearchTotalhitsBySinglePhrase(targetQs[i], searchRankType, bNoAds, bOfficial);
}
TopDocs topDocs = null;
if (searchRankType == SearchRankType.DOWNLOAD || searchRankType == SearchRankType.ONLY_NAME_DOWNLOAD) {
topDocs = TopDocs.merge(sortByDownloadRank, Integer.MAX_VALUE, topDocsArray);
} else {
topDocs = TopDocs.merge(null, Integer.MAX_VALUE, topDocsArray);
}
return TopDocsUtil.mergeDuplicateDocId(topDocs);
}