Tai Le :
I have a function that receive an Aggregation aggregation
as a param.
I would like to get all AggregationOperation
from aggregation
. Is there any way to do it?
public Aggregation newCustomAggregation(Aggregation aggregation, Criteria c) {
// How to get list operation aggregation there?
listOperation.push(Aggregation.match(c));
return Aggregation
.newAggregation(listOperations);
}
My purpose is new another Aggregation
with my custom MatchAggregation
.
Sagar Veeram :
You can create your own custom aggregation implementation by subclassing the aggregation to access the protected operations field.
Something like
public class CustomAggregation extends Aggregation {
List<AggregationOperation> getAggregationOperations() {
return operations;
}
}
public Aggregation newCustomAggregation(Aggregation aggregation, Criteria c) {
CustomAggregation customAggregation = (CustomAggregation) aggregation;
List<AggregationOperation> listOperations = customAggregation.getAggregationOperations();
listOperations.add(Aggregation.match(c));
return Aggregation .newAggregation(listOperations);
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=460886&siteId=1