本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}