AggregationBuilders.count(COUNT).field(FIELD_ISSUE_KEY)) .subAggregation( AggregationBuilders.max("maxFuncCreatedAt").field(FIELD_ISSUE_FUNC_CREATED_AT)))); }); SearchResponse response = request.get();
@Override protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metaData) { return new MaxAggregationBuilder(this, factoriesBuilder, metaData); }
final FilterAggregationBuilder builder = AggregationBuilders.filter("agg", QueryBuilders.existsQuery(Message.FIELD_TIMESTAMP)) .subAggregation(AggregationBuilders.min("ts_min").field(Message.FIELD_TIMESTAMP)) .subAggregation(AggregationBuilders.max("ts_max").field(Message.FIELD_TIMESTAMP)) .subAggregation(AggregationBuilders.terms("streams").field(Message.FIELD_STREAMS)); final String query = searchSource()
/** * Create a new {@link Max} aggregation with the given name. */ public static MaxAggregationBuilder max(String name) { return new MaxAggregationBuilder(name); }
private AbstractAggregationBuilder parseStatsAggregation(SQLAggregateExpr aggExpr, String fieldName) { ElasticSqlMethodInvokeHelper.checkStatAggMethod(aggExpr); String methodName = aggExpr.getMethodName(); if (ElasticSqlMethodInvokeHelper.AGG_MIN_METHOD.equalsIgnoreCase(methodName)) { return AggregationBuilders.min(String.format("%s_%s", ElasticSqlMethodInvokeHelper.AGG_MIN_METHOD, fieldName)).field(fieldName); } if (ElasticSqlMethodInvokeHelper.AGG_MAX_METHOD.equalsIgnoreCase(methodName)) { return AggregationBuilders.max(String.format("%s_%s", ElasticSqlMethodInvokeHelper.AGG_MAX_METHOD, fieldName)).field(fieldName); } if (ElasticSqlMethodInvokeHelper.AGG_AVG_METHOD.equalsIgnoreCase(methodName)) { return AggregationBuilders.avg(String.format("%s_%s", ElasticSqlMethodInvokeHelper.AGG_AVG_METHOD, fieldName)).field(fieldName); } if (ElasticSqlMethodInvokeHelper.AGG_SUM_METHOD.equalsIgnoreCase(methodName)) { return AggregationBuilders.sum(String.format("%s_%s", ElasticSqlMethodInvokeHelper.AGG_SUM_METHOD, fieldName)).field(fieldName); } throw new ElasticSql2DslException(String.format("[syntax error] UnSupport agg method call[%s]", methodName)); } }
public static AggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException { return PARSER.parse(parser, new MaxAggregationBuilder(aggregationName), null); }
AggregationBuilders.count("count").field(IssueIndexDefinition.FIELD_ISSUE_KEY)) .subAggregation( AggregationBuilders.max("maxFuncCreatedAt").field(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT)))); }); SearchResponse response = request.get();
/** * Create a new {@link Max} aggregation with the given name. */ public static MaxAggregationBuilder max(String name) { return new MaxAggregationBuilder(name); }
/** * Ensures the audit sequence returns an UID greater or equal than the maximum log entry id. */ protected void ensureUIDSequencer(ESClient esClient) { boolean auditIndexExists = esClient.indexExists(getESIndexName()); if (!auditIndexExists) { return; } // Get max log entry id SearchRequest request = createSearchRequest(); request.source(new SearchSourceBuilder().query(QueryBuilders.matchAllQuery()) .aggregation(AggregationBuilders.max("maxAgg").field("id"))); SearchResponse searchResponse = esClient.search(request); Max agg = searchResponse.getAggregations().get("maxAgg"); long maxLogEntryId = (long) agg.getValue(); // Get next sequence id UIDGeneratorService uidGeneratorService = Framework.getService(UIDGeneratorService.class); UIDSequencer seq = uidGeneratorService.getSequencer(); seq.init(); long nextSequenceId = seq.getNextLong(SEQ_NAME); // Increment sequence to max log entry id if needed if (nextSequenceId < maxLogEntryId) { log.info(String.format("Next UID returned by %s sequence is %d, initializing sequence to %d", SEQ_NAME, nextSequenceId, maxLogEntryId)); seq.initSequence(SEQ_NAME, maxLogEntryId); } }
/** * Create a new {@link Max} aggregation with the given name. */ public static MaxAggregationBuilder max(String name) { return new MaxAggregationBuilder(name); }
/** * Create a new {@link Max} aggregation with the given name. */ public static MaxAggregationBuilder max(String name) { return new MaxAggregationBuilder(name); }
/** * Creates an AggregationBuilder for the supplied type */ public AggregationBuilder toBuilder(String type) { switch (type) { case AGG_CARDINALITY: return AggregationBuilders.cardinality(getId()).field(getField()); case AGG_COUNT: return AggregationBuilders.count(getId()).field(getField()); case AGG_SUM: return AggregationBuilders.sum(getId()).field(getField()); case AGG_AVG: return AggregationBuilders.avg(getId()).field(getField()); case AGG_MAX: return AggregationBuilders.max(getId()).field(getField()); case AGG_MIN: return AggregationBuilders.min(getId()).field(getField()); default: throw new IllegalArgumentException("Unknown aggregate type: " + type); } }
@Override protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metaData) { return new MaxAggregationBuilder(this, factoriesBuilder, metaData); }
@Override protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metaData) { return new MaxAggregationBuilder(this, factoriesBuilder, metaData); }
public static AggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException { return PARSER.parse(parser, new MaxAggregationBuilder(aggregationName), null); }
public static AggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException { return PARSER.parse(parser, new MaxAggregationBuilder(aggregationName), null); }
public static AggregationBuilder parse(String aggregationName, QueryParseContext context) throws IOException { return PARSER.parse(context.parser(), new MaxAggregationBuilder(aggregationName), context); }