private Map<String, Aggregate> collectAggregates(NodeState defn) {
Map<String, Aggregate> aggregateMap = newHashMap();
for (ChildNodeEntry cne : defn.getChildNode(FulltextIndexConstants.AGGREGATES).getChildNodeEntries()) {
String nodeType = cne.getName();
int recursionLimit = getOptionalValue(cne.getNodeState(), FulltextIndexConstants.AGG_RECURSIVE_LIMIT,
Aggregate.RECURSIVE_AGGREGATION_LIMIT_DEFAULT);
List<Aggregate.Include> includes = newArrayList();
for (ChildNodeEntry include : cne.getNodeState().getChildNodeEntries()) {
NodeState is = include.getNodeState();
String primaryType = is.getString(FulltextIndexConstants.AGG_PRIMARY_TYPE);
String path = is.getString(FulltextIndexConstants.AGG_PATH);
boolean relativeNode = getOptionalValue(is, FulltextIndexConstants.AGG_RELATIVE_NODE, false);
if (path == null) {
log.warn("Aggregate pattern in {} does not have required property [{}]. {} aggregate rule would " +
"be ignored", this, FulltextIndexConstants.AGG_PATH, include.getName());
continue;
}
includes.add(new Aggregate.NodeInclude(this, primaryType, path, relativeNode));
}
aggregateMap.put(nodeType, new Aggregate(nodeType, includes, recursionLimit));
}
return ImmutableMap.copyOf(aggregateMap);
}