当前位置: 首页>>代码示例>>Java>>正文


Java AggregationBuilders.terms方法代码示例

本文整理汇总了Java中org.elasticsearch.search.aggregations.AggregationBuilders.terms方法的典型用法代码示例。如果您正苦于以下问题:Java AggregationBuilders.terms方法的具体用法?Java AggregationBuilders.terms怎么用?Java AggregationBuilders.terms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.search.aggregations.AggregationBuilders的用法示例。


在下文中一共展示了AggregationBuilders.terms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGroupsTermBuilder

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private TermsAggregationBuilder getGroupsTermBuilder(GroupRequest groupRequest, int index) {
  List<Group> groups = groupRequest.getGroups();
  Group group = groups.get(index);
  String aggregationName = getGroupByAggregationName(group.getField());
  TermsAggregationBuilder termsBuilder = AggregationBuilders.terms(aggregationName);
  termsBuilder
      .field(group.getField())
      .size(accessConfig.getMaxSearchGroups())
      .order(getElasticsearchGroupOrder(group.getOrder()));
  if (index < groups.size() - 1) {
    termsBuilder.subAggregation(getGroupsTermBuilder(groupRequest, index + 1));
  }
  Optional<String> scoreField = groupRequest.getScoreField();
  if (scoreField.isPresent()) {
    SumAggregationBuilder scoreSumAggregationBuilder = AggregationBuilders.sum(getSumAggregationName(scoreField.get())).field(scoreField.get()).missing(0);
    termsBuilder.subAggregation(scoreSumAggregationBuilder);
  }
  return termsBuilder;
}
 
开发者ID:apache,项目名称:metron,代码行数:20,代码来源:ElasticsearchDao.java

示例2: getFacetBuilder

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
public static AggregationBuilder getFacetBuilder(MultiValueFacet multiValueFacet) {
    FacetConfiguration facetConfiguration = multiValueFacet.getFacetConfiguration();
    JSONObject facetData = facetConfiguration.getData();

    if (multiValueFacet.isStatic()) {
        return null;
    }
    TermsBuilder termsFacetBuilder = AggregationBuilders.terms(facetConfiguration.getFieldName());
    if (facetData.has("maxTerms")) {
        termsFacetBuilder.size(facetData.getInt("maxTerms"));
    }
    termsFacetBuilder.field(facetConfiguration.getFieldName());
    return termsFacetBuilder;
}
 
开发者ID:R-Knowsys,项目名称:elasticray,代码行数:15,代码来源:LiferayFacetParser.java

示例3: termsAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder termsAgg(MethodField field) throws SqlParseException {
    String aggName = gettAggNameFromParamsOrAlias(field);
    TermsAggregationBuilder terms = AggregationBuilders.terms(aggName);
    String value = null;
    for (KVValue kv : field.getParams()) {
        value = kv.value.toString();
        switch (kv.key.toLowerCase()) {
            case "field":
                terms.field(value);
                break;
            case "size":
                terms.size(Integer.parseInt(value));
                break;
            case "shard_size":
                terms.shardSize(Integer.parseInt(value));
                break;
            case "min_doc_count":
                terms.minDocCount(Integer.parseInt(value));
                break;
            case "missing":
                terms.missing(value);
                break;
            case "order":
                if ("asc".equalsIgnoreCase(value)) {
                    terms.order(Terms.Order.term(true));
                } else if ("desc".equalsIgnoreCase(value)) {
                    terms.order(Terms.Order.term(false));
                } else {
                    throw new SqlParseException("order can only support asc/desc " + kv.toString());
                }
                break;
            case "alias":
            case "nested":
            case "reverse_nested":
            case "children":
                break;
            default:
                throw new SqlParseException("terms aggregation err or not define field " + kv.toString());
        }
    }
    return terms;
}
 
开发者ID:mazhou,项目名称:es-sql,代码行数:43,代码来源:AggMaker.java

示例4: termsAgg

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
private AggregationBuilder termsAgg(MethodField field) throws SqlParseException {
    String aggName = gettAggNameFromParamsOrAlias(field);
    TermsAggregationBuilder terms = AggregationBuilders.terms(aggName);
    String value = null;
    for (KVValue kv : field.getParams()) {
        value = kv.value.toString();
        switch (kv.key.toLowerCase()) {
            case "field":
                terms.field(value);
                break;
            case "size":
                terms.size(Integer.parseInt(value));
                break;
            case "shard_size":
                terms.shardSize(Integer.parseInt(value));
                break;
            case "min_doc_count":
                terms.minDocCount(Integer.parseInt(value));
                break;
            case "missing":
                terms.missing(value);
                break;
            case "order":
                if ("asc".equalsIgnoreCase(value)) {
                    terms.order(BucketOrder.key(true));
                } else if ("desc".equalsIgnoreCase(value)) {
                    terms.order(BucketOrder.key(false));
                } else {
                    throw new SqlParseException("order can only support asc/desc " + kv.toString());
                }
                break;
            case "alias":
            case "nested":
            case "reverse_nested":
            case "children":
                break;
            case "execution_hint":
                terms.executionHint(value);
                break;
            default:
                throw new SqlParseException("terms aggregation err or not define field " + kv.toString());
        }
    }
    return terms;
}
 
开发者ID:NLPchina,项目名称:elasticsearch-sql,代码行数:46,代码来源:AggMaker.java

示例5: SimpleAggregationBuilder

import org.elasticsearch.search.aggregations.AggregationBuilders; //导入方法依赖的package包/类
/***
 * 
"aggs": {
       "hots": {
           "terms": {
               "field": "keyword"
           }
       }
 * @param name
 * @param field
 * @return
 */
public SimpleAggregationBuilder(PB parentBuilder, String name, String field, Integer size) {
	this(parentBuilder, AggregationBuilders.terms(name), field, size);
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:16,代码来源:SimpleSearchQueryBuilder.java


注:本文中的org.elasticsearch.search.aggregations.AggregationBuilders.terms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。