From 3375c02b42f834a7aa4656a993ca2fac5307c383 Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Tue, 17 Feb 2015 11:14:47 +0000 Subject: [PATCH] Added support for _count and _key as bucketsPaths --- .../search/aggregations/AggregatorFactories.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java b/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java index 258b90c2653..628fe3144a9 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java +++ b/src/main/java/org/elasticsearch/search/aggregations/AggregatorFactories.java @@ -157,7 +157,7 @@ public class AggregatorFactories { } public AggregatorFactories build() { - if (factories.isEmpty()) { + if (factories.isEmpty() && reducerFactories.isEmpty()) { return EMPTY; } List orderedReducers = resolveReducerOrder(this.reducerFactories, this.factories); @@ -212,7 +212,7 @@ public class AggregatorFactories { String[] bucketsPaths = factory.getBucketsPaths(); for (String bucketsPath : bucketsPaths) { ReducerFactory matchingFactory = reducerFactoriesMap.get(bucketsPath); - if (aggFactoryNames.contains(bucketsPath)) { + if (bucketsPath.equals("_count") || bucketsPath.equals("_key") || aggFactoryNames.contains(bucketsPath)) { continue; } else if (matchingFactory != null) { resolveReducerOrder(aggFactoryNames, reducerFactoriesMap, orderedReducers, unmarkedFactories, temporarilyMarked,