Commit 3a0dd477 by 姚冰

[chg] 聚合解析修正,结果字段修正

1 parent d16d3a99
......@@ -16,7 +16,8 @@ public class SearchResultHit {
private String _score;
private Integer age;
private String gender;
private Integer bodyType;
private Integer body_type;
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private String counttime;
private String fid;
......
......@@ -170,8 +170,8 @@ public class PersonService {
pool.setPersonPoolId(id);
if (poolService.existPool(id)) {
pool.setStatus(0);
// List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg);
// matchFaces.addAll(face);
List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg);
matchFaces.addAll(face);
List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg);
matchBodies.addAll(body);
} else {
......@@ -566,9 +566,14 @@ public class PersonService {
// log.info("request:{}", JSON.tojsonS);
SearchResponse<SearchResultHit> search = client.search(searchRequest, SearchResultHit.class);
if (agg) {
Map aggregations = search.aggregations();
TermsAggregation byPersonId = (TermsAggregation) aggregations.get("by_personId");
log.info("aggregation:{}", byPersonId.toString());
StringTermsAggregate byPersonId = (StringTermsAggregate) search.aggregations().get("by_personId")._get();
for (StringTermsBucket bucket : byPersonId.buckets().array()) {
String personId = bucket.key().stringValue();
MaxAggregate maxAggregate = (MaxAggregate) bucket.aggregations().get("max_score")._get();
double value = maxAggregate.value();
Person person = new Person().setPersonId(personId).setScore((float) value).setPersonPoolId(poolId);
persons.add(person);
}
// List<Bucket> buckets = byPersonId.;
// for (Terms.Bucket bucket : buckets) {
// String personId = (String) bucket.getKey();
......@@ -588,7 +593,7 @@ public class PersonService {
p.setAge(hit.getAge());
p.setGender((String) hit.getGender());
p.setChannelSerialNum(hit.getChannelSerialNum());
p.setBodyType(hit.getBodyType());
p.setBodyType(hit.getBody_type());
p.setCaptureUnid(hit.getUnid());
p.setPersonType(hit.getPersonType());
p.setCounttime(Optional.ofNullable((String)hit.getCounttime())
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!