|
@@ -12,7 +12,13 @@ import cn.cslg.pas.domain.es.FamilyPatent;
|
|
|
import cn.cslg.pas.domain.es.PatentFamilyMessage;
|
|
|
import cn.cslg.pas.service.business.ProductMarketDataService;
|
|
|
import cn.cslg.pas.service.business.es.EsService;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.AggregationBuilders;
|
|
|
+import co.elastic.clients.elasticsearch._types.aggregations.CalendarInterval;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
|
|
+import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -199,7 +205,54 @@ public class EventServiceTests {
|
|
|
|
|
|
@Test
|
|
|
void test5() throws IOException {
|
|
|
- SelectClaimDTO dto = esService.selectClaim("CN102324864A");
|
|
|
- System.out.println(dto);
|
|
|
+// SelectClaimDTO dto = esService.selectClaim("CN102324864A");
|
|
|
+// System.out.println(dto);
|
|
|
+
|
|
|
+ Aggregation range = AggregationBuilders.range(n -> n.field("app_date").format("yyyy"));
|
|
|
+ Aggregation aggregation = AggregationBuilders.dateHistogram(i -> i.field("app_date").format("yyyy").calendarInterval(CalendarInterval.Year));
|
|
|
+ Query query = QueryBuilders.range(j -> j.field("app_date").from("2021").to("2023"));
|
|
|
+ Aggregation filter = AggregationBuilders.filter(n -> n.bool(k -> k.must(query)));
|
|
|
+ aggregation.aggregations().put("filter_agg",filter);
|
|
|
+
|
|
|
+ System.out.println(aggregation);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void test6() {
|
|
|
+ String valueOne = "H02";
|
|
|
+ Aggregation aggregation = AggregationBuilders.terms(i -> i.field("mipc.level2").size(10));
|
|
|
+ if (StringUtils.isNotEmpty(valueOne)) {
|
|
|
+ Query query = QueryBuilders.term(j -> j.field("mipc.level2").value(valueOne));
|
|
|
+ Aggregation filter = AggregationBuilders.filter(n -> n.bool(k -> k.must(query)));
|
|
|
+ Map<String, Aggregation> map = aggregation.aggregations();
|
|
|
+ System.out.println(map + "----------------");
|
|
|
+ map.put("filter_agg", filter);
|
|
|
+ System.out.println(map);
|
|
|
+ }
|
|
|
+ System.out.println(aggregation);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void test7() {
|
|
|
+ String valueOne = "";
|
|
|
+ Aggregation terms = AggregationBuilders.terms(j -> j.field("applicant.name.key").size(10));
|
|
|
+ if (StringUtils.isNotEmpty(valueOne)) {
|
|
|
+ Query query = QueryBuilders.term(j -> j.field("applicant.name.key").value(valueOne));
|
|
|
+ Aggregation filter = AggregationBuilders.filter(n -> n.bool(k -> k.must(query)));
|
|
|
+ terms.aggregations().put("filter_agg",filter);
|
|
|
+ }
|
|
|
+ Aggregation aggregation = AggregationBuilders.nested(i -> i.path("applicant")).aggregations().put("terms_agg", terms);
|
|
|
+ System.out.println(aggregation);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void test8() {
|
|
|
+ String valueOne = "";
|
|
|
+ String str = "*";
|
|
|
+ String s = str.concat(valueOne).concat("*");
|
|
|
+ Query query = QueryBuilders.wildcard(i -> i.field("").value(s));
|
|
|
+ Aggregation aggregation = AggregationBuilders.filter(i -> i.bool(j -> j.must(query)));
|
|
|
+ System.out.println(aggregation);
|
|
|
}
|
|
|
}
|