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