Java = 8 ElasticSearchServer = 7.16.3
My code never returns the value for aggregations , I tried most of the combinations. Below is the code , please see if you can help here
@Repository
public interface ScPayHkIndexRepository extends ElasticsearchRepository<ScPayHkIndex, String> {
Stream<ScPayHkIndex> findByStatusNotAndExceptionTypeAndTimestampBetween(String status, String exceptionType, long from, long to);
Stream<ScPayHkIndex> findByPaymentTypeAndTimestampBetween(String paymentType, long from, long to);
@Query(("{\"bool\": {\"must\": [{\"match\": {\"status\": \"Completed\"}}]}},\"aggs\": {\"percentAggs\": {\"percentile_ranks\": {\"field\": \"Total_Time\"}}}"))
SearchHits<ScPayHkIndex> getPercentileRank();
default double getMyPercentileValue() {
SearchHits<ScPayHkIndex> response = getPercentileRank();
Aggregations aggregation = response.getAggregations();
PercentileRanks percentileRanks = aggregation.get("percentAggs");
// Get the desired percentile value using the percentile() method of the Percentiles object
double myPercentileValue = percentileRanks.percent(5000);
return myPercentileValue;
}