NativeSearchQuery build1 = new NativeSearchQueryBuilder()
                .withFilter(rangeQuery("releaseDate").gte(1538841600000L).lte(1539446400000L))
                .addAggregation(AggregationBuilders.dateHistogram("releaseDate").field("releaseDate").dateHistogramInterval(DateHistogramInterval.DAY)
                        .subAggregation(AggregationBuilders.terms("type").field("sourceType")))
                .build();

我希望通过代码达到相同的效果
我的springdataElasticSearch版本是3.2.3RELEASE

最佳答案

我已经解决了问题。
NativeSearchQuery build1 = new NativeSearchQueryBuilder() .withQuery(boolQuery().filter(rangeQuery("releaseDate").gte(1538841600000L).lte(1539446400000L))) .addAggregation(AggregationBuilders.dateHistogram("ReleaseDate").field("releaseDate").dateHistogramInterval(DateHistogramInterval.DAY).subAggregation(AggregationBuilders.terms("Type").field("sourceType")))

09-10 16:14