Commit 3a0dd477 by 姚冰

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

1 parent d16d3a99
...@@ -16,7 +16,8 @@ public class SearchResultHit { ...@@ -16,7 +16,8 @@ public class SearchResultHit {
private String _score; private String _score;
private Integer age; private Integer age;
private String gender; private String gender;
private Integer bodyType;
private Integer body_type;
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") // @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private String counttime; private String counttime;
private String fid; private String fid;
......
...@@ -170,8 +170,8 @@ public class PersonService { ...@@ -170,8 +170,8 @@ public class PersonService {
pool.setPersonPoolId(id); pool.setPersonPoolId(id);
if (poolService.existPool(id)) { if (poolService.existPool(id)) {
pool.setStatus(0); pool.setStatus(0);
// List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg); List<Person> face = matchPerson(rid, id, requestVo.getPerson(), 0, size, agg);
// matchFaces.addAll(face); matchFaces.addAll(face);
List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg); List<Person> body = matchPerson(rid, id, requestVo.getPerson(), 1, size, agg);
matchBodies.addAll(body); matchBodies.addAll(body);
} else { } else {
...@@ -566,9 +566,14 @@ public class PersonService { ...@@ -566,9 +566,14 @@ public class PersonService {
// log.info("request:{}", JSON.tojsonS); // log.info("request:{}", JSON.tojsonS);
SearchResponse<SearchResultHit> search = client.search(searchRequest, SearchResultHit.class); SearchResponse<SearchResultHit> search = client.search(searchRequest, SearchResultHit.class);
if (agg) { if (agg) {
Map aggregations = search.aggregations(); StringTermsAggregate byPersonId = (StringTermsAggregate) search.aggregations().get("by_personId")._get();
TermsAggregation byPersonId = (TermsAggregation) aggregations.get("by_personId"); for (StringTermsBucket bucket : byPersonId.buckets().array()) {
log.info("aggregation:{}", byPersonId.toString()); 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.; // List<Bucket> buckets = byPersonId.;
// for (Terms.Bucket bucket : buckets) { // for (Terms.Bucket bucket : buckets) {
// String personId = (String) bucket.getKey(); // String personId = (String) bucket.getKey();
...@@ -588,7 +593,7 @@ public class PersonService { ...@@ -588,7 +593,7 @@ public class PersonService {
p.setAge(hit.getAge()); p.setAge(hit.getAge());
p.setGender((String) hit.getGender()); p.setGender((String) hit.getGender());
p.setChannelSerialNum(hit.getChannelSerialNum()); p.setChannelSerialNum(hit.getChannelSerialNum());
p.setBodyType(hit.getBodyType()); p.setBodyType(hit.getBody_type());
p.setCaptureUnid(hit.getUnid()); p.setCaptureUnid(hit.getUnid());
p.setPersonType(hit.getPersonType()); p.setPersonType(hit.getPersonType());
p.setCounttime(Optional.ofNullable((String)hit.getCounttime()) 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!