首页 > 其他分享 >springboot ElasticsearchRepository date_histogram 聚合查询

springboot ElasticsearchRepository date_histogram 聚合查询

时间:2023-02-20 10:45:23浏览次数:48  
标签:ElasticsearchRepository springboot nsqb search queryBuilder 查询 date

       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);

  

标签:ElasticsearchRepository,springboot,nsqb,search,queryBuilder,查询,date
From: https://www.cnblogs.com/isyysblog/p/17136516.html

相关文章