org.elasticsearch.search.aggregations.HasAggregations Java Examples
The following examples show how to use
org.elasticsearch.search.aggregations.HasAggregations.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FactSearchManager.java From act-platform with ISC License | 6 votes |
private Aggregation resolveChildAggregation(Aggregations aggregations, String targetAggregationName) { if (aggregations == null) return null; for (Aggregation aggregation : aggregations) { // Check if 'aggregation' is already the target aggregation. if (aggregation.getName().equals(targetAggregationName)) { return aggregation; } // Otherwise check all sub aggregations if applicable. if (HasAggregations.class.isAssignableFrom(aggregation.getClass())) { Aggregation target = resolveChildAggregation(HasAggregations.class.cast(aggregation).getAggregations(), targetAggregationName); if (target != null) return target; } } // Couldn't find target aggregation. return null; }
Example #2
Source File: SimpleSearchQueryBuilder.java From onetwo with Apache License 2.0 | 6 votes |
public <T extends Aggregation> T getAggregationByPath(List<String> paths) { this.checkAggs(); T agg = aggregations.get(paths.get(0)); for (int i = 1; i < paths.size(); i++) { String attr = paths.get(i); if(agg instanceof HasAggregations){ HasAggregations hasagg = (HasAggregations) agg; agg = hasagg.getAggregations().get(attr); }else if(agg instanceof MultiBucketsAggregation){ MultiBucketsAggregation magg = (MultiBucketsAggregation) agg; if(magg.getBuckets().isEmpty()){ return agg; } Bucket bucket = magg.getBuckets().get(0); agg = bucket.getAggregations().get(attr); }else{ break; } } return agg; }