springboot ElasticsearchRepository date_histogram 聚合查询

       NativeSearchQueryBuilder nsqb = new NativeSearchQueryBuilder();
            DateHistogramAggregationBuilder dhb = AggregationBuilders.dateHistogram("passenger_flow").field("timeString")
            .dateHistogramInterval(DateHistogramInterval.DAY)
                    .minDocCount(0)
                    .format("yyyy-MM-dd")
                    .extendedBounds(new ExtendedBounds("2023-02-10", "2023-02-16"));
            nsqb.addAggregation(dhb);
            //查询对象
            SearchQuery queryBuilder = nsqb.build();
            Iterable<ExtCallbackStatisticsES> aIterable = extCallbackStatisticsESMapper.search(queryBuilder);
       extCallbackStatisticsESMapper.search(queryBuilder);

  

posted @ 2023-02-20 10:37  90的生力军  阅读(76)  评论(0编辑  收藏  举报