|
@@ -516,139 +516,20 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
|
|
Query q = formatQueryService.EsQueryToQuery((operateNode) tree, "patent", projectId);
|
|
builder.query(q);
|
|
builder.query(q);
|
|
if (type == 0) {
|
|
if (type == 0) {
|
|
- Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue()));
|
|
|
|
- Aggregation termAgg = new Aggregation.Builder().terms(i -> i.field("merge_applicant.name.raw").size(100000))
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("termAgg", bucketSort);
|
|
|
|
- }}).build();
|
|
|
|
- Aggregation aggregation = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_applicant").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("nestedAgg", termAgg);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("Agg", aggregation);
|
|
|
|
-
|
|
|
|
- //对聚合结果统计出总数
|
|
|
|
- Aggregation terms = AggregationBuilders.terms(i -> i.field("merge_applicant.name.raw").size(100000));
|
|
|
|
- BucketsPath bucketsPath = BucketsPath.of(i -> i.single("terms>_count"));
|
|
|
|
- Aggregation statsBucket = AggregationBuilders.statsBucket(i -> i.bucketsPath(bucketsPath));
|
|
|
|
- Aggregation totalAgg = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_applicant").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("terms", terms);
|
|
|
|
- put("statsBucket", statsBucket);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("totalAgg", totalAgg);
|
|
|
|
-
|
|
|
|
- //权利人
|
|
|
|
- Aggregation bucketSort1 = AggregationBuilders.bucketSort(i -> i.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue()));
|
|
|
|
- Aggregation termAgg1 = new Aggregation.Builder().terms(i -> i.field("merge_right_holder.name.raw").size(100000))
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("rightTermAgg", bucketSort1);
|
|
|
|
- }}).build();
|
|
|
|
- Aggregation aggregation1 = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_right_holder").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("rightNestedAgg", termAgg1);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("rightAgg", aggregation1);
|
|
|
|
|
|
+ this.loadAppAndRightAgg(builder,pageNum.intValue(),pageSize.intValue());
|
|
} else {
|
|
} else {
|
|
- Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue()));
|
|
|
|
- Aggregation termAgg = new Aggregation.Builder().terms(i -> i.field("merge_inventor.name.raw").size(100000))
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("termAgg", bucketSort);
|
|
|
|
- }}).build();
|
|
|
|
- Aggregation aggregation = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_inventor").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("nestedAgg", termAgg);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("Agg", aggregation);
|
|
|
|
-
|
|
|
|
- //对聚合结果统计出总数
|
|
|
|
- Aggregation terms = AggregationBuilders.terms(i -> i.field("merge_inventor.name.raw").size(100000));
|
|
|
|
- BucketsPath bucketsPath = BucketsPath.of(i -> i.single("terms>_count"));
|
|
|
|
- Aggregation statsBucket = AggregationBuilders.statsBucket(i -> i.bucketsPath(bucketsPath));
|
|
|
|
- Aggregation totalAgg = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_inventor").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("terms", terms);
|
|
|
|
- put("statsBucket", statsBucket);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("totalAgg", totalAgg);
|
|
|
|
|
|
+ this.loadInventorAgg(builder,pageNum.intValue(),pageSize.intValue());
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (type == 0) {
|
|
if (type == 0) {
|
|
//申请人
|
|
//申请人
|
|
- Query q1 = QueryBuilders.term(i -> i.field("merge_applicant.project_id").value(projectId));
|
|
|
|
- Query nestedQ1 = QueryBuilders.nested(i -> i.path("merge_applicant").query(q1));
|
|
|
|
- Query q2 = QueryBuilders.term(i -> i.field("merge_right_holder.project_id").value(projectId));
|
|
|
|
- Query nestedQ2 = QueryBuilders.nested(i -> i.path("merge_right_holder").query(q2));
|
|
|
|
- Query bool = QueryBuilders.bool(i -> i.should(nestedQ1, nestedQ2));
|
|
|
|
- builder.query(bool);
|
|
|
|
- Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue()));
|
|
|
|
- Aggregation termAgg = new Aggregation.Builder().terms(i -> i.field("merge_applicant.name.raw").size(100000))
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("termAgg", bucketSort);
|
|
|
|
- }}).build();
|
|
|
|
- Aggregation aggregation = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_applicant").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("nestedAgg", termAgg);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("Agg", aggregation);
|
|
|
|
-
|
|
|
|
- //对聚合结果统计出总数
|
|
|
|
- Aggregation terms = AggregationBuilders.terms(i -> i.field("merge_applicant.name.raw").size(100000));
|
|
|
|
- BucketsPath bucketsPath = BucketsPath.of(i -> i.single("terms>_count"));
|
|
|
|
- Aggregation statsBucket = AggregationBuilders.statsBucket(i -> i.bucketsPath(bucketsPath));
|
|
|
|
- Aggregation totalAgg = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_applicant").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("terms", terms);
|
|
|
|
- put("statsBucket", statsBucket);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("totalAgg", totalAgg);
|
|
|
|
-
|
|
|
|
- //权利人
|
|
|
|
- Aggregation bucketSort1 = AggregationBuilders.bucketSort(i -> i.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue()));
|
|
|
|
- Aggregation termAgg1 = new Aggregation.Builder().terms(i -> i.field("merge_right_holder.name.raw").size(100000))
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("rightTermAgg", bucketSort1);
|
|
|
|
- }}).build();
|
|
|
|
- Aggregation aggregation1 = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_right_holder").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("rightNestedAgg", termAgg1);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("rightAgg", aggregation1);
|
|
|
|
|
|
+ Query query = this.loadQueryByType(type, projectId);
|
|
|
|
+ builder.query(query);
|
|
|
|
+ this.loadAppAndRightAgg(builder,pageNum.intValue(),pageSize.intValue());
|
|
} else {
|
|
} else {
|
|
- Query q = QueryBuilders.term(i -> i.field("merge_inventor.project_id").value(projectId));
|
|
|
|
- Query nestedQ = QueryBuilders.nested(i -> i.path("merge_inventor").query(q));
|
|
|
|
- builder.query(nestedQ);
|
|
|
|
- Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from((pageNum.intValue() - 1) * pageSize.intValue()).size(pageSize.intValue()));
|
|
|
|
- Aggregation termAgg = new Aggregation.Builder().terms(i -> i.field("merge_inventor.name.raw").size(100000))
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("termAgg", bucketSort);
|
|
|
|
- }}).build();
|
|
|
|
- Aggregation aggregation = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_inventor").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("nestedAgg", termAgg);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("Agg", aggregation);
|
|
|
|
-
|
|
|
|
- //对聚合结果统计出总数
|
|
|
|
- Aggregation terms = AggregationBuilders.terms(i -> i.field("merge_inventor.name.raw").size(100000));
|
|
|
|
- BucketsPath bucketsPath = BucketsPath.of(i -> i.single("terms>_count"));
|
|
|
|
- Aggregation statsBucket = AggregationBuilders.statsBucket(i -> i.bucketsPath(bucketsPath));
|
|
|
|
- Aggregation totalAgg = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
- path("merge_inventor").build())
|
|
|
|
- .aggregations(new HashMap() {{
|
|
|
|
- put("terms", terms);
|
|
|
|
- put("statsBucket", statsBucket);
|
|
|
|
- }}).build();
|
|
|
|
- builder.aggregations("totalAgg", totalAgg);
|
|
|
|
|
|
+ Query query = this.loadQueryByType(type, projectId);
|
|
|
|
+ builder.query(query);
|
|
|
|
+ this.loadInventorAgg(builder,pageNum.intValue(),pageSize.intValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -658,92 +539,16 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
Aggregate totalAggregate = totalAgg.nested().aggregations().get("statsBucket");
|
|
Aggregate totalAggregate = totalAgg.nested().aggregations().get("statsBucket");
|
|
long total = totalAggregate.statsBucket().count();
|
|
long total = totalAggregate.statsBucket().count();
|
|
|
|
|
|
-
|
|
|
|
List<String> mergeList = new ArrayList<>();
|
|
List<String> mergeList = new ArrayList<>();
|
|
if (StringUtils.isNotEmpty(condition)) {
|
|
if (StringUtils.isNotEmpty(condition)) {
|
|
- Aggregate terms = totalAgg.nested().aggregations().get("terms");
|
|
|
|
- List<StringTermsBucket> termsBucketList = terms.sterms().buckets().array();
|
|
|
|
- if (condition.contains("AND") && operate.equals("AND")) {
|
|
|
|
- String[] parts = condition.split(" AND ");
|
|
|
|
- for (String part : parts) {
|
|
|
|
- List<String> expresses = getConditionExpress(part);
|
|
|
|
- List<String> merges = termsBucketList.stream().map(StringTermsBucket::key).map(FieldValue::stringValue)
|
|
|
|
- .filter(value -> expresses.stream().anyMatch(express -> value.contains(express)))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- total = total > merges.size() ? merges.size() : total;
|
|
|
|
- merges = merges.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
|
- if (CollectionUtils.isEmpty(mergeList)) {
|
|
|
|
- mergeList.addAll(merges);
|
|
|
|
- } else {
|
|
|
|
- merges.retainAll(mergeList);
|
|
|
|
- mergeList = new ArrayList<>(merges);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- List<String> expresses = getConditionExpress(condition);
|
|
|
|
- List<String> merges = termsBucketList.stream().map(StringTermsBucket::key).map(FieldValue::stringValue)
|
|
|
|
- .filter(value -> expresses.stream().anyMatch(express -> value.contains(express)))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
- total = total > merges.size() ? merges.size() : total;
|
|
|
|
- merges = merges.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
|
- mergeList.addAll(merges);
|
|
|
|
- }
|
|
|
|
|
|
+ total = this.loadConditionMergeList(totalAgg,mergeList,condition,operate,total,pageNum.intValue(),pageSize.intValue());
|
|
} else {
|
|
} else {
|
|
- if (type == 0) {
|
|
|
|
- Aggregate agg = response.aggregations().get("Agg");
|
|
|
|
- Aggregate nestedAgg = agg.nested().aggregations().get("nestedAgg");
|
|
|
|
- List<StringTermsBucket> buckets = nestedAgg.sterms().buckets().array();
|
|
|
|
- for (StringTermsBucket bucket : buckets) {
|
|
|
|
- String value = bucket.key().stringValue();
|
|
|
|
- mergeList.add(value);
|
|
|
|
- }
|
|
|
|
- Aggregate rightAgg = response.aggregations().get("rightAgg");
|
|
|
|
- Aggregate rightNestedAgg = rightAgg.nested().aggregations().get("rightNestedAgg");
|
|
|
|
- List<StringTermsBucket> bucketList = rightNestedAgg.sterms().buckets().array();
|
|
|
|
- if (!CollectionUtils.isEmpty(bucketList)) {
|
|
|
|
- for (StringTermsBucket bucket : bucketList) {
|
|
|
|
- String value = bucket.key().stringValue();
|
|
|
|
- mergeList.add(value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Aggregate inventorAgg = response.aggregations().get("Agg");
|
|
|
|
- Aggregate inventorNestedAgg = inventorAgg.nested().aggregations().get("nestedAgg");
|
|
|
|
- List<StringTermsBucket> bucketList = inventorNestedAgg.sterms().buckets().array();
|
|
|
|
- if (!CollectionUtils.isEmpty(bucketList)) {
|
|
|
|
- for (StringTermsBucket bucket : bucketList) {
|
|
|
|
- String value = bucket.key().stringValue();
|
|
|
|
- mergeList.add(value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ loadMergeList(type, response, mergeList);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
List<String> nameList = mergeList.stream().distinct().collect(Collectors.toList());
|
|
List<String> nameList = mergeList.stream().distinct().collect(Collectors.toList());
|
|
if (!CollectionUtils.isEmpty(nameList)) {
|
|
if (!CollectionUtils.isEmpty(nameList)) {
|
|
- for (String name : nameList) {
|
|
|
|
- MergePerson person = mergePersonMapper.selectOne(new LambdaQueryWrapper<MergePerson>()
|
|
|
|
- .eq(MergePerson::getProjectId, projectId)
|
|
|
|
- .eq(MergePerson::getType, type)
|
|
|
|
- .eq(MergePerson::getName, name));
|
|
|
|
- if (!ObjectUtils.isEmpty(person)) {
|
|
|
|
- GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
|
|
- dto.setName(name);
|
|
|
|
- dto.setMergeId(person.getId());
|
|
|
|
- dto.setType(person.getType());
|
|
|
|
- dto.setRemark(person.getRemark());
|
|
|
|
- dto.setAbbreviation(person.getAbbreviation());
|
|
|
|
- dto.setCountry(person.getCountry());
|
|
|
|
- dto.setProvince(person.getProvince());
|
|
|
|
- dto.setAddress(person.getAddress());
|
|
|
|
- personList.add(dto);
|
|
|
|
- } else {
|
|
|
|
- GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
|
|
- dto.setName(name);
|
|
|
|
- personList.add(dto);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ personList = this.loadMergedDetail(nameList, projectId, type);
|
|
}
|
|
}
|
|
List<GetAllPersonDTO> collect = personList.stream().filter(i -> !StringUtils.isEmpty(i.getName())).collect(Collectors.toList());
|
|
List<GetAllPersonDTO> collect = personList.stream().filter(i -> !StringUtils.isEmpty(i.getName())).collect(Collectors.toList());
|
|
|
|
|
|
@@ -760,6 +565,175 @@ public class MergePersonService extends ServiceImpl<MergePersonMapper, MergePers
|
|
return records;
|
|
return records;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public List<GetAllPersonDTO> loadMergedDetail(List<String> nameList, Integer projectId, Integer type) {
|
|
|
|
+ List<GetAllPersonDTO> personList = new ArrayList<>();
|
|
|
|
+ for (String name : nameList) {
|
|
|
|
+ MergePerson person = mergePersonMapper.selectOne(new LambdaQueryWrapper<MergePerson>()
|
|
|
|
+ .eq(MergePerson::getProjectId, projectId)
|
|
|
|
+ .eq(MergePerson::getType, type)
|
|
|
|
+ .eq(MergePerson::getName, name));
|
|
|
|
+ if (!ObjectUtils.isEmpty(person)) {
|
|
|
|
+ GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
|
|
+ dto.setName(name);
|
|
|
|
+ dto.setMergeId(person.getId());
|
|
|
|
+ dto.setType(person.getType());
|
|
|
|
+ dto.setRemark(person.getRemark());
|
|
|
|
+ dto.setAbbreviation(person.getAbbreviation());
|
|
|
|
+ dto.setCountry(person.getCountry());
|
|
|
|
+ dto.setProvince(person.getProvince());
|
|
|
|
+ dto.setAddress(person.getAddress());
|
|
|
|
+ personList.add(dto);
|
|
|
|
+ } else {
|
|
|
|
+ GetAllPersonDTO dto = new GetAllPersonDTO();
|
|
|
|
+ dto.setName(name);
|
|
|
|
+ personList.add(dto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return personList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void loadMergeList(Integer type,SearchResponse<Patent> response,List<String> mergeList) {
|
|
|
|
+ if (type == 0) {
|
|
|
|
+ Aggregate agg = response.aggregations().get("Agg");
|
|
|
|
+ Aggregate nestedAgg = agg.nested().aggregations().get("nestedAgg");
|
|
|
|
+ List<StringTermsBucket> buckets = nestedAgg.sterms().buckets().array();
|
|
|
|
+ for (StringTermsBucket bucket : buckets) {
|
|
|
|
+ String value = bucket.key().stringValue();
|
|
|
|
+ mergeList.add(value);
|
|
|
|
+ }
|
|
|
|
+ Aggregate rightAgg = response.aggregations().get("rightAgg");
|
|
|
|
+ Aggregate rightNestedAgg = rightAgg.nested().aggregations().get("rightNestedAgg");
|
|
|
|
+ List<StringTermsBucket> bucketList = rightNestedAgg.sterms().buckets().array();
|
|
|
|
+ if (!CollectionUtils.isEmpty(bucketList)) {
|
|
|
|
+ for (StringTermsBucket bucket : bucketList) {
|
|
|
|
+ String value = bucket.key().stringValue();
|
|
|
|
+ mergeList.add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Aggregate inventorAgg = response.aggregations().get("Agg");
|
|
|
|
+ Aggregate inventorNestedAgg = inventorAgg.nested().aggregations().get("nestedAgg");
|
|
|
|
+ List<StringTermsBucket> bucketList = inventorNestedAgg.sterms().buckets().array();
|
|
|
|
+ if (!CollectionUtils.isEmpty(bucketList)) {
|
|
|
|
+ for (StringTermsBucket bucket : bucketList) {
|
|
|
|
+ String value = bucket.key().stringValue();
|
|
|
|
+ mergeList.add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public long loadConditionMergeList(Aggregate totalAgg, List<String> mergeList, String condition,
|
|
|
|
+ String operate, long total, Integer pageNum, Integer pageSize) {
|
|
|
|
+ Aggregate terms = totalAgg.nested().aggregations().get("terms");
|
|
|
|
+ List<StringTermsBucket> termsBucketList = terms.sterms().buckets().array();
|
|
|
|
+ if (condition.contains("AND") && operate.equals("AND")) {
|
|
|
|
+ String[] parts = condition.split(" AND ");
|
|
|
|
+ for (String part : parts) {
|
|
|
|
+ List<String> expresses = getConditionExpress(part);
|
|
|
|
+ List<String> merges = termsBucketList.stream().map(StringTermsBucket::key).map(FieldValue::stringValue)
|
|
|
|
+ .filter(value -> expresses.stream().anyMatch(express -> value.contains(express)))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ total = total > merges.size() ? merges.size() : total;
|
|
|
|
+ merges = merges.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
|
+ if (CollectionUtils.isEmpty(mergeList)) {
|
|
|
|
+ mergeList.addAll(merges);
|
|
|
|
+ } else {
|
|
|
|
+ merges.retainAll(mergeList);
|
|
|
|
+ mergeList = new ArrayList<>(merges);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ List<String> expresses = getConditionExpress(condition);
|
|
|
|
+ List<String> merges = termsBucketList.stream().map(StringTermsBucket::key).map(FieldValue::stringValue)
|
|
|
|
+ .filter(value -> expresses.stream().anyMatch(express -> value.contains(express.toLowerCase(Locale.ROOT))))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ total = total > merges.size() ? merges.size() : total;
|
|
|
|
+ merges = merges.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
|
+ mergeList.addAll(merges);
|
|
|
|
+ }
|
|
|
|
+ return total;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Query loadQueryByType(Integer type,Integer projectId) {
|
|
|
|
+ Map<Integer, Query> map = new HashMap<>();
|
|
|
|
+ Query q1 = QueryBuilders.term(i -> i.field("merge_applicant.project_id").value(projectId));
|
|
|
|
+ Query nestedQ1 = QueryBuilders.nested(i -> i.path("merge_applicant").query(q1));
|
|
|
|
+ Query q2 = QueryBuilders.term(i -> i.field("merge_right_holder.project_id").value(projectId));
|
|
|
|
+ Query nestedQ2 = QueryBuilders.nested(i -> i.path("merge_right_holder").query(q2));
|
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.should(nestedQ1, nestedQ2));
|
|
|
|
+ map.put(0, bool);
|
|
|
|
+ Query q = QueryBuilders.term(i -> i.field("merge_inventor.project_id").value(projectId));
|
|
|
|
+ Query nestedQ = QueryBuilders.nested(i -> i.path("merge_inventor").query(q));
|
|
|
|
+ map.put(2, nestedQ);
|
|
|
|
+ return map.get(type);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void loadAppAndRightAgg(SearchRequest.Builder builder, Integer pageNum, Integer pageSize) {
|
|
|
|
+ Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from((pageNum - 1) * pageSize).size(pageSize));
|
|
|
|
+ Aggregation termAgg = new Aggregation.Builder().terms(i -> i.field("merge_applicant.name.raw").size(100000))
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("termAgg", bucketSort);
|
|
|
|
+ }}).build();
|
|
|
|
+ Aggregation aggregation = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
+ path("merge_applicant").build())
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("nestedAgg", termAgg);
|
|
|
|
+ }}).build();
|
|
|
|
+ builder.aggregations("Agg", aggregation);
|
|
|
|
+
|
|
|
|
+ //对聚合结果统计出总数
|
|
|
|
+ Aggregation terms = AggregationBuilders.terms(i -> i.field("merge_applicant.name.raw").size(100000));
|
|
|
|
+ BucketsPath bucketsPath = BucketsPath.of(i -> i.single("terms>_count"));
|
|
|
|
+ Aggregation statsBucket = AggregationBuilders.statsBucket(i -> i.bucketsPath(bucketsPath));
|
|
|
|
+ Aggregation totalAgg = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
+ path("merge_applicant").build())
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("terms", terms);
|
|
|
|
+ put("statsBucket", statsBucket);
|
|
|
|
+ }}).build();
|
|
|
|
+ builder.aggregations("totalAgg", totalAgg);
|
|
|
|
+
|
|
|
|
+ //权利人
|
|
|
|
+ Aggregation bucketSort1 = AggregationBuilders.bucketSort(i -> i.from((pageNum - 1) * pageSize).size(pageSize));
|
|
|
|
+ Aggregation termAgg1 = new Aggregation.Builder().terms(i -> i.field("merge_right_holder.name.raw").size(100000))
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("rightTermAgg", bucketSort1);
|
|
|
|
+ }}).build();
|
|
|
|
+ Aggregation aggregation1 = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
+ path("merge_right_holder").build())
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("rightNestedAgg", termAgg1);
|
|
|
|
+ }}).build();
|
|
|
|
+ builder.aggregations("rightAgg", aggregation1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void loadInventorAgg(SearchRequest.Builder builder, Integer pageNum, Integer pageSize) {
|
|
|
|
+ Aggregation bucketSort = AggregationBuilders.bucketSort(i -> i.from((pageNum - 1) * pageSize).size(pageSize));
|
|
|
|
+ Aggregation termAgg = new Aggregation.Builder().terms(i -> i.field("merge_inventor.name.raw").size(100000))
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("termAgg", bucketSort);
|
|
|
|
+ }}).build();
|
|
|
|
+ Aggregation aggregation = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
+ path("merge_inventor").build())
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("nestedAgg", termAgg);
|
|
|
|
+ }}).build();
|
|
|
|
+ builder.aggregations("Agg", aggregation);
|
|
|
|
+
|
|
|
|
+ //对聚合结果统计出总数
|
|
|
|
+ Aggregation terms = AggregationBuilders.terms(i -> i.field("merge_inventor.name.raw").size(100000));
|
|
|
|
+ BucketsPath bucketsPath = BucketsPath.of(i -> i.single("terms>_count"));
|
|
|
|
+ Aggregation statsBucket = AggregationBuilders.statsBucket(i -> i.bucketsPath(bucketsPath));
|
|
|
|
+ Aggregation totalAgg = new Aggregation.Builder().nested(new NestedAggregation.Builder().
|
|
|
|
+ path("merge_inventor").build())
|
|
|
|
+ .aggregations(new HashMap() {{
|
|
|
|
+ put("terms", terms);
|
|
|
|
+ put("statsBucket", statsBucket);
|
|
|
|
+ }}).build();
|
|
|
|
+ builder.aggregations("totalAgg", totalAgg);
|
|
|
|
+ }
|
|
|
|
+
|
|
private List<String> getConditionExpress(String input) {
|
|
private List<String> getConditionExpress(String input) {
|
|
// 编写正则表达式来匹配 = 后面的双括号内的内容
|
|
// 编写正则表达式来匹配 = 后面的双括号内的内容
|
|
String regex = "=\\(\\(([^)]*)\\)\\)";
|
|
String regex = "=\\(\\(([^)]*)\\)\\)";
|