I want to have a method that loops through an ArrayList and based on it's content dynamically generate x amount of Keyed Filters
List<KeyedFilter> filters = new ArrayList<KeyedFilter>();
for (String a: b) {
filters.add(generateKeyedFilterFromList(a.key, a.value, a.buckets);
}
private KeyedFilter (generateKeyedFilterFromList(String key, String value, String[] buckets) {
KeyedFilter filter = new KeyedFilter(key,
QueryBuilder(value, buckets));
}
this return the list of KeyedFilters just fine, however I have yet to find a way to apply it to AggregationBuilder (String, KeyedFilter...)
AggregationBuilder agg = AggregationBuilders.filter("filterName", filters);
tried an array
KeyedFilter[] filterArray = new KeyedFilter[filters.size()];
filterArray = filters.toArray(filterArray);
AggregationBuilder agg = AggregationBuilders.filter("filterName", filterArray); // honestly I am not completely sure why this doesn't work here