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


Java TopDocs.merge方法代碼示例

本文整理匯總了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;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:SearchPhaseControllerTests.java

示例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);
}
 
開發者ID:zhaoxi1988,項目名稱:sjk,代碼行數:70,代碼來源:SearchService1Impl.java


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