123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package cn.cslg.pas.service.business.es;
- import cn.cslg.pas.common.dto.PatentDTO;
- import cn.cslg.pas.common.dto.business.EsCountDTO;
- import cn.cslg.pas.common.model.request.QueryRequest;
- import cn.cslg.pas.common.vo.business.EsCountVO;
- import cn.cslg.pas.domain.es.Patent;
- import co.elastic.clients.elasticsearch.ElasticsearchClient;
- import co.elastic.clients.elasticsearch._types.aggregations.AggregateBuilders;
- import co.elastic.clients.elasticsearch._types.aggregations.Aggregation;
- import co.elastic.clients.elasticsearch._types.aggregations.AggregationBuilders;
- import co.elastic.clients.elasticsearch._types.aggregations.NestedAggregate;
- import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
- import co.elastic.clients.elasticsearch.core.SearchRequest;
- import co.elastic.clients.elasticsearch.core.SearchResponse;
- import lombok.RequiredArgsConstructor;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- @Service
- @RequiredArgsConstructor(onConstructor_ = {@Lazy})
- public class EsCountService {
- private final ElasticsearchClient client;
- /**
- * 查询专利库中的专利分组聚合统计
- * @param vo
- * @return
- * @throws Exception
- */
- public EsCountDTO esCountSearch(EsCountVO vo) throws Exception {
- String field = vo.getField();
- String value = vo.getValue();
- Integer topN = vo.getTopN();
- EsCountDTO esCountDTO = new EsCountDTO();
- SearchRequest.Builder builder = new SearchRequest.Builder();
- builder.index("patent");
- if (field.equals("applicant")) {
- }
- if (field.equals("rightHolder")) {
- }
- if (field.equals("mipc")) {
- }
- if (field.equals("appDate")) {
- }
- // AggregationBuilders.terms(i -> i.field()).field()
- SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
- return esCountDTO;
- }
- }
|