From fd500746694b2f2032c8339905ec64e257429310 Mon Sep 17 00:00:00 2001 From: "Yangkai.Shen" <237497819@qq.com> Date: Fri, 21 Dec 2018 15:18:55 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=B7=BB=E5=8A=A0=E8=81=9A?= =?UTF-8?q?=E5=90=88=E6=9F=A5=E8=AF=A2=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elasticsearch/repository/PersonRepositoryTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot-demo-elasticsearch/src/test/java/com/xkcoding/elasticsearch/repository/PersonRepositoryTest.java b/spring-boot-demo-elasticsearch/src/test/java/com/xkcoding/elasticsearch/repository/PersonRepositoryTest.java index 509ed8c..b62f196 100644 --- a/spring-boot-demo-elasticsearch/src/test/java/com/xkcoding/elasticsearch/repository/PersonRepositoryTest.java +++ b/spring-boot-demo-elasticsearch/src/test/java/com/xkcoding/elasticsearch/repository/PersonRepositoryTest.java @@ -1,6 +1,7 @@ package com.xkcoding.elasticsearch.repository; import cn.hutool.core.date.DateUtil; +import cn.hutool.json.JSONUtil; import com.google.common.collect.Lists; import com.xkcoding.elasticsearch.SpringBootDemoElasticsearchApplicationTests; import com.xkcoding.elasticsearch.model.Person; @@ -152,7 +153,7 @@ public class PersonRepositoryTest extends SpringBootDemoElasticsearchApplication // 平均年龄 queryBuilder.addAggregation(AggregationBuilders.avg("avg").field("age")); - log.info("【queryBuilder.build()】= {}", queryBuilder.build().toString()); + log.info("【queryBuilder】= {}", JSONUtil.toJsonStr(queryBuilder.build())); AggregatedPage people = (AggregatedPage) repo.search(queryBuilder.build()); double avgAge = ((InternalAvg) people.getAggregation("avg")).getValue(); @@ -174,7 +175,7 @@ public class PersonRepositoryTest extends SpringBootDemoElasticsearchApplication // 2. 在国家聚合桶内进行嵌套聚合,求平均年龄 .subAggregation(AggregationBuilders.avg("avg").field("age"))); - log.info("【queryBuilder.build()】= {}", queryBuilder.build().toString()); + log.info("【queryBuilder】= {}", JSONUtil.toJsonStr(queryBuilder.build())); // 3. 查询 AggregatedPage people = (AggregatedPage) repo.search(queryBuilder.build());