diff --git a/ai-xuebao-admin/pom.xml b/ai-xuebao-admin/pom.xml
index 782bafd..520e163 100644
--- a/ai-xuebao-admin/pom.xml
+++ b/ai-xuebao-admin/pom.xml
@@ -74,11 +74,6 @@
lombok
provided
-
- com.github.whvcse
- easy-captcha
- 1.6.2
-
org.bouncycastle
diff --git a/ai-xuebao-es/src/main/java/net/hzvtc/service/impl/EsRecordReportServiceImpl.java b/ai-xuebao-es/src/main/java/net/hzvtc/service/impl/EsRecordReportServiceImpl.java
index c0d129d..e75ed9c 100644
--- a/ai-xuebao-es/src/main/java/net/hzvtc/service/impl/EsRecordReportServiceImpl.java
+++ b/ai-xuebao-es/src/main/java/net/hzvtc/service/impl/EsRecordReportServiceImpl.java
@@ -3,7 +3,6 @@ package net.hzvtc.service.impl;
import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.elasticsearch._types.FieldValue;
import co.elastic.clients.elasticsearch._types.SortOrder;
-import co.elastic.clients.elasticsearch._types.Time;
import co.elastic.clients.elasticsearch._types.aggregations.*;
import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
import co.elastic.clients.elasticsearch.core.SearchRequest;
@@ -1310,7 +1309,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
JSONObject obj = new JSONObject();
obj.put("speciesId", speciesId);
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
- obj.put("count", (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put("count", (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
array.add(obj);
});
object.put("list", array);
@@ -1363,7 +1362,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
searchRequest = new SearchRequest.Builder().index(validIndexName) //
.query(q -> q.bool(boolQueryBuilder.build())).size(0) //
.aggregations("by_record_time", agg -> agg.dateHistogram(t -> t.field("record_time").timeZone("+08:00")//
- .calendarInterval(CalendarInterval.Hour).format("HH").offset(Time.of(tm -> tm.time("-6h"))))//
+ .calendarInterval(CalendarInterval.Hour).format("HH"))//
.aggregations("by_media_type", mt -> mt.terms(t -> t.field("media_type").size(10)).aggregations("by_species_id", m -> m.terms(t -> t.field("species_id").size(10000))//
.aggregations("sum_value", sumAgg -> sumAgg.sum(sm -> sm.field("count")))))).build();
} else {
@@ -1699,7 +1698,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
List fieldValues = idList.stream().map(FieldValue::of).collect(Collectors.toList());
return f.filter(ft -> ft.terms(t2 -> t2.field("items.species_id").terms(v -> v.value(fieldValues)))).aggregations("by_species_id",
d -> d.terms(t2 -> t2.field("items.species_id").size(10000)).aggregations("sum_value",
- sumAgg -> sumAgg.sum(m -> m.field("items.count"))));
+ sumAgg -> sumAgg.sum(m -> m.field("items.count"))).aggregations("parent_docs",
+ rn -> rn.reverseNested(r -> r).aggregations("doc_count",
+ vc -> vc.valueCount(m -> m.field("id")))));
} else {
String excludeIds = param.getString("excludeIds");
if (excludeIds != null && !excludeIds.isEmpty()) {
@@ -1713,11 +1714,15 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
return f.filter(ft -> ft.bool(b -> b.mustNot(mn -> mn.terms(t2 -> t2.field("items.species_id")
.terms(v -> v.value(fieldValues)))))).aggregations("by_species_id",
d -> d.terms(t2 -> t2.field("items.species_id").size(10000))
- .aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count"))));
+ .aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count")))
+ .aggregations("parent_docs", rn -> rn.reverseNested(r -> r)
+ .aggregations("doc_count", vc -> vc.valueCount(m -> m.field("id")))));
} else {
return f.aggregations("by_species_id", d -> d.terms(t2 -> t2.field("items.species_id").size(10000))
- .aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count"))));
+ .aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("items.count")))
+ .aggregations("parent_docs", rn -> rn.reverseNested(r -> r)
+ .aggregations("doc_count", vc -> vc.valueCount(m -> m.field("id")))));
}
}
@@ -1734,7 +1739,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
.format(dateFormat)//
.minDocCount(0)).aggregations("by_media_type", mt -> mt.terms(t -> t.field("media_type").size(10))
.aggregations("by_species_id", d -> d.terms(s -> s.field("species_id").size(10000))
- .aggregations("sum_value", sumAgg -> sumAgg.sum(m -> m.field("count")))))).build();
+ .aggregations("media_count", m -> m.cardinality(c2 -> c2.field("media_id")))))).build();
try {
SearchResponse searchResponse = elasticsearchClient.search(searchRequest, Void.class);
List array = new ArrayList<>();
@@ -1762,9 +1767,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
obj = new JSONObject();
obj.put("speciesId", speciesId);
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
} else {
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
}
map.put(speciesId, obj);
});
@@ -1824,9 +1829,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
obj = new JSONObject();
obj.put("speciesId", speciesId);
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
} else {
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
}
map.put(speciesId, obj);
});
@@ -1940,7 +1945,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
.aggregations("by_device_id", Aggregation.of(a -> a.terms(TermsAggregation.of(t -> t.field("device_id").size(10000))) //
.aggregations("by_media_type", Aggregation.of(mt -> mt.terms(TermsAggregation.of(t -> t.field("media_type").size(10))) //
.aggregations("items_path", Aggregation.of(n -> n.nested(ne -> ne.path("items")) //
- .aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("items.species_id").size(10000))))))))))).build();
+ .aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("items.species_id").size(10000)))
+ .aggregations("parent_docs", Aggregation.of(rn -> rn.reverseNested(r -> r)
+ .aggregations("doc_count", Aggregation.of(vc -> vc.valueCount(m -> m.field("id")))))))))))))).build();
try {
Map birdMap = new HashMap<>();
@@ -1972,7 +1979,7 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
long speciesId = speciesBucket.key();
sub.put("speciesId", speciesId);
sub.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
- sub.put("count", speciesBucket.docCount());
+ sub.put("count", (int) speciesBucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
// 根据媒体类型分类存放,2通常代表图片,3通常代表视频
if (mediaType == 2) {
imgList.add(sub);
@@ -2132,8 +2139,8 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
.query(q -> q.bool(boolQueryBuilder.build())).size(0) //
.aggregations("by_media_type", Aggregation.of(a -> a.terms(TermsAggregation.of(t -> t.field("media_type").size(10) //
))//
- .aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("species_id").size(10000))).aggregations("sum_value",//
- sumAgg -> sumAgg.sum(m -> m.field("count"))))))).build();
+ .aggregations("by_species_id", Aggregation.of(c -> c.terms(TermsAggregation.of(t -> t.field("species_id").size(10000)))
+ .aggregations("media_count", Aggregation.of(m -> m.cardinality(c2 -> c2.field("media_id")))))))).build();
try {
SearchResponse searchResponse = elasticsearchClient.search(searchRequest, Void.class);
Map aggregations = searchResponse.aggregations();
@@ -2153,9 +2160,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
obj = new JSONObject();
obj.put("speciesId", speciesId);
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
} else {
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("media_count").cardinality().value());
}
map.put(speciesId, obj);
});
@@ -2342,9 +2349,9 @@ public class EsRecordReportServiceImpl implements EsRecordReportService {
obj = new JSONObject();
obj.put("speciesId", speciesId);
obj.put("speciesName", getSpeciesNameByName(speciesId, birdMap));
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
} else {
- obj.put(key, (int) bucket.aggregations().get("sum_value").sum().value());
+ obj.put(key, (int) bucket.aggregations().get("parent_docs").reverseNested().aggregations().get("doc_count").valueCount().value());
}
map.put(speciesId, obj);
});