当前位置: 首页>>代码示例>>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;未经允许,请勿转载。