I recently upgraded to Spring 3 which means there were small adjustments needed for some of my queries/aggregations written in elasticsearch java. I cannot figure out how to get the .order(SortOrder.Asc) to work again in the current version. This is what my Aggregation used to look like:
new Aggregation.Builder().dateHistogram(
d -> d.field("timestamp")
.calendarInterval(...)
.format(...)
.order(HistogramOrder.of(h -> h.key(SortOrder.Asc)))
.minDocCount(0)
.extendedBounds(
e -> e.max(...)
.min(...)
)
);
now the .order(...) seems to take a NamedValue, so I tried
.order(NamedValue.of("ascending", SortOrder.Asc))
this however, only gives me an error when trying to execute the query:
"type":"aggregation_execution_exception","reason":"Invalid aggregation order path [ascending]. The provided aggregation [ascending] either does not exist, or is a pipeline aggregation and cannot be used to sort the buckets."
I can't say I understand the error completely and how to fix it! Is there a different way of ordering these buckets now? Any help appreciated!