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


Java SearchHits.getTotalHits方法代碼示例

本文整理匯總了Java中org.elasticsearch.search.SearchHits.getTotalHits方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchHits.getTotalHits方法的具體用法?Java SearchHits.getTotalHits怎麽用?Java SearchHits.getTotalHits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.search.SearchHits的用法示例。


在下文中一共展示了SearchHits.getTotalHits方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIterable

import org.elasticsearch.search.SearchHits; //導入方法依賴的package包/類
protected <T> ElasticsearchGraphQueryIterable<T> createIterable(
        SearchResponse response,
        QueryParameters filterParameters,
        Iterable<T> MemgraphObjects,
        boolean evaluateQueryString,
        boolean evaluateHasContainers,
        boolean evaluateSortContainers,
        long searchTimeInMillis,
        SearchHits hits
) {
    return new ElasticsearchGraphQueryIterable<>(
            this,
            response,
            filterParameters,
            MemgraphObjects,
            evaluateQueryString,
            evaluateHasContainers,
            evaluateSortContainers,
            hits.getTotalHits(),
            searchTimeInMillis * 1000000,
            hits
    );
}
 
開發者ID:mware-solutions,項目名稱:memory-graph,代碼行數:24,代碼來源:ElasticsearchSearchQueryBase.java

示例2: queryByEsQueryDo

import org.elasticsearch.search.SearchHits; //導入方法依賴的package包/類
public EsResponse queryByEsQueryDo(EsQueryDo esQueryObj) throws EsException {
    validationEsQuery(esQueryObj.getIndexName(),esQueryObj.getTypeName());
    //創建ES查詢Request對象
    SearchRequestBuilder esSearch=buildSearchRequest (esQueryObj);
    //執行查詢
    SearchResponse response =esSearch.execute().actionGet();
    JSONObject resObj = new JSONObject();
    //獲取facet結果
    if(!Check.NuNObject(esQueryObj.aggregationFields())){
        parseAggregationResult(response, esQueryObj.aggregationFields(), resObj);
    }
    //1、獲取搜索的文檔結果
    SearchHits searchHits = response.getHits();
    if (searchHits == null || searchHits.getTotalHits() == 0) {
        return EsResponse.responseOK(null);
    }
    SearchHit[] hits = searchHits.getHits();
    resObj.put("total", searchHits.getTotalHits());
    //1.1、獲取搜索結果
    parseSearchResult(hits, esQueryObj.isHighLigth(), esQueryObj, resObj);
    return EsResponse.responseOK(resObj);
}
 
開發者ID:AsuraTeam,項目名稱:asura,代碼行數:23,代碼來源:EsQuery.java

示例3: SearchResult

import org.elasticsearch.search.SearchHits; //導入方法依賴的package包/類
public SearchResult(SearchResponse resp) {
	SearchHits hits = resp.getHits();
	this.total = hits.getTotalHits();
	results = new ArrayList<>(hits.getHits().length);
	for (SearchHit searchHit : hits.getHits()) {
		if (searchHit.getSource() != null) {
			results.add(searchHit.getSource());
		} else if (searchHit.getFields() != null) {
			Map<String, SearchHitField> fields = searchHit.getFields();
			results.add(toFieldsMap(fields));
		}

	}
}
 
開發者ID:mazhou,項目名稱:es-sql,代碼行數:15,代碼來源:SearchResult.java

示例4: convertToDocumentsAndTotalCount

import org.elasticsearch.search.SearchHits; //導入方法依賴的package包/類
@Nonnull
@Override
public <T extends AbstractEsDocument> DocumentsAndTotalCount<T> convertToDocumentsAndTotalCount(@Nonnull final SearchResponse searchResponse,
                                                                                                @Nonnull final Class<T> clazz) {
    assertSearchResponseNotNull(searchResponse);
    assertClazzNotNull(clazz);
    final SearchHits searchHits = searchResponse.getHits();
    final List<T> documents = extractDocuments(searchHits, clazz);
    return new DocumentsAndTotalCount<>(documents, searchHits.getTotalHits());
}
 
開發者ID:Biacode,項目名稱:escommons,代碼行數:11,代碼來源:SearchResponseComponentImpl.java

示例5: search

import org.elasticsearch.search.SearchHits; //導入方法依賴的package包/類
/**
 * 查詢
 *
 * @param queryBuilder
 * @param type
 * @param sortField    排序字段
 * @param desc
 * @param from         分頁起始偏移量
 * @param size         頁麵大小
 * @return
 */
private static <T> Pagination<T> search(QueryBuilder queryBuilder, IndexType type, String sortField, boolean desc, int from, int size) {
    List<T> results = new ArrayList<>();
    //不同的索引 變量 代碼通用
    SearchRequestBuilder serachBuilder = EsClientManager.getClient().prepareSearch(esprop.getIndice())
            .setTypes(type.getDataName())
            .setQuery(queryBuilder);
    if (!StringUtils.isEmpty(sortField)) {
        if (sortField.equalsIgnoreCase(SortMode.ORDERVALUE_ASC.getSortField())) {
            serachBuilder.addSort("_score", SortOrder.DESC);
        }
        serachBuilder.addSort(sortField, desc ? SortOrder.DESC : SortOrder.ASC);
    }
    if (0 != size) {
        serachBuilder.setFrom(from).setSize(size);
    }
    SearchResponse response = serachBuilder.execute().actionGet();
    SearchHits searchHits = response.getHits();
    SearchHit[] hits = searchHits.getHits();
    for (SearchHit hit : hits) {
        results.add((T) EsDataUtil.readValue(hit.source(), type.getTypeClass()));
    }
    int total = (int) searchHits.getTotalHits();
    Pagination pagination = new Pagination();
    pagination.setDataList(results);
    pagination.setTotalCount(total);
    return pagination;
}
 
開發者ID:wxz1211,項目名稱:dooo,代碼行數:39,代碼來源:IndexManager.java


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