Commit fa91890d by 朱海

[chg]人员库支持不同的比对分数

1 parent b7916465
......@@ -22,8 +22,9 @@ public class PersonInfo {
private String channelSerialNum;
private Long gateId;
private String direction;
private Long personType;
public PersonInfo(String unid, String personId, Double[] body,Double[] data, Integer age, String gender, Integer bodyType, Date countTime, String fid, String channelSerialNum, Long gateId, String direction) {
public PersonInfo(String unid, String personId, Double[] body,Double[] data, Integer age, String gender, Integer bodyType, Date countTime, String fid, String channelSerialNum, Long gateId, String direction, Long personType) {
this.unid = unid;
this.personId = personId;
this.body = body;
......@@ -37,5 +38,6 @@ public class PersonInfo {
this.gateId = gateId;
this.direction = direction;
this._score = "1";
this.personType = personType;
}
}
......@@ -23,4 +23,5 @@ public class SearchResultHit {
private String channelSerialNum;
private Long gateId;
private String direction;
private Long personType;
}
......@@ -49,7 +49,7 @@ import java.util.stream.Stream;
@Service
@Slf4j
public class PersonService {
private static final String[] FETCH_SOURCE = new String[]{"personId", "age", "gender", "fid", "counttime", "channelSerialNum", "body_type","unid"};
private static final String[] FETCH_SOURCE = new String[]{"personId", "age", "gender", "fid", "counttime", "channelSerialNum", "body_type","unid","personType"};
@Resource
private ElasticsearchClient client;
......@@ -257,6 +257,7 @@ public class PersonService {
String direction = person.getDirection();
//Long gateId = person.getGateId();
Integer bodyType = person.getBodyType();
Long personType = person.getPersonType();
String personChannelSerialNum = person.getChannelSerialNum();
List<FaceFeature> faceFeatures = person.getFaceFeatures();
if (CollectionUtils.isNotEmpty(faceFeatures)) {
......@@ -273,7 +274,7 @@ public class PersonService {
// "counttime", personCountTime == null ? null : Constant.DATE_FORMAT.get().format(personCountTime),
// "channelSerialNum", personChannelSerialNum, "gateId", gateId, "direction", direction);
// bulkRequest.add(indexRequest);
operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction)).build()).build());
operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction, personType)).build()).build());
}
}
}
......@@ -303,7 +304,7 @@ public class PersonService {
// "counttime", counttime == null ? null : Constant.DATE_FORMAT.get().format(counttime)
// , "channelSerialNum", channelSerialNum, "gateId", gateId, "direction", direction);
// bulkRequest.add(indexRequest);
operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction)).build()).build());
operationList.add(new BulkOperation.Builder().index(new IndexOperation.Builder<PersonInfo>().index(poolId).document(new PersonInfo(unid, personId, feature, null, age, gender, bodyType, personCountTime, fid, personChannelSerialNum, gateId, direction, personType)).build()).build());
}
}
}
......@@ -537,11 +538,19 @@ public class PersonService {
} else {
// builder.size(matchResultSize);
}
Float matchScore = null;
Map<String, Float> poolMatchScoreMap = person.getPoolMatchScoreMap();
if (poolMatchScoreMap != null) {
matchScore = poolMatchScoreMap.get(poolId);
}
if (matchScore == null) {
matchScore = person.getBodyMinScore();
}
SourceConfig sourceConfig = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build();
// log.debug("rid:{} poolId:{} 匹配时参数:{}", rid, poolId, scriptScoreQuery.toString());
// KnnSearch knnQuery = getKnnSearch(feature, person, type);
// ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, type);
return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(sourceConfig).size(matchResultSize).minScore(person.getBodyMinScore().doubleValue()/100).build();
return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(sourceConfig).size(matchResultSize).minScore(matchScore.doubleValue()/100).build();
}
private List<Person> match0(SearchRequest searchRequest, Boolean agg) throws Exception {
......@@ -574,7 +583,7 @@ public class PersonService {
p.setChannelSerialNum(hit.getChannelSerialNum());
p.setBodyType(hit.getBodyType());
p.setCaptureUnid(hit.getUnid());
p.setPersonType(hit.getPersonType());
p.setCounttime(Optional.ofNullable((String)hit.getCounttime())
.map(x -> {
try {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!