Commit 7ebc9871 by 姚冰

[chg] 部分条件修改,去除部分日志,添加超时参数

1 parent 113515d4
...@@ -154,7 +154,7 @@ public class PersonService { ...@@ -154,7 +154,7 @@ public class PersonService {
if (poolId != null) { if (poolId != null) {
poolIds.add(poolId); poolIds.add(poolId);
} }
log.info("人员匹配操作开始,PoolIds:[{}],rid:{}", poolIds, rid); // log.info("人员匹配操作开始,PoolIds:[{}],rid:{}", poolIds, rid);
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
try { try {
for (String id : poolIds) { for (String id : poolIds) {
...@@ -162,8 +162,8 @@ public class PersonService { ...@@ -162,8 +162,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 {
...@@ -374,7 +374,7 @@ public class PersonService { ...@@ -374,7 +374,7 @@ public class PersonService {
matchResult.addAll(match0(searchRequest, agg)); matchResult.addAll(match0(searchRequest, agg));
} }
} else { } else {
log.info("no face feature"); // log.info("no face feature");
} }
} }
...@@ -452,51 +452,35 @@ public class PersonService { ...@@ -452,51 +452,35 @@ public class PersonService {
// .build()._toQuery(); // .build()._toQuery();
// queries.add(query); // queries.add(query);
knnQuery.field("data").queryVector(getFeature(feature)).numCandidates(Constant.FACE_MATCH_RESULT_SIZE); knnQuery.field("data").queryVector(getFeature(feature)).numCandidates(Constant.FACE_MATCH_RESULT_SIZE);
// script = new Script(
// ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG,
// "(cosineSimilarity(params.face, 'data') + 1) / 2 * 100", Collections.singletonMap("face", feature));
// boolQuery.filter(QueryBuilders.existsQuery("data"));
} else if (null != feature && type == 1){ } else if (null != feature && type == 1){
// Query query = QueryBuilders.knn()
// .field("body")
// .queryVector(getFeature(feature))
// .numCandidates(Constant.FACE_MATCH_RESULT_SIZE)
// .similarity(person.getBodyMinScore())
//// .similarity("l2_norm")
// .build()._toQuery();
// queries.add(query);
knnQuery.field("body").queryVector(getFeature(feature)).numCandidates(Constant.FACE_MATCH_RESULT_SIZE); knnQuery.field("body").queryVector(getFeature(feature)).numCandidates(Constant.FACE_MATCH_RESULT_SIZE);
// knnQuery.field("body").numCandidates(Constant.FACE_MATCH_RESULT_SIZE);
// script = new Script(
// ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG,
// "(cosineSimilarity(params.body, 'body') + 1) / 2 * 100", Collections.singletonMap("body", feature));
// boolQuery.filter(QueryBuilders.existsQuery("body"));
queries.add(new Query.Builder().exists(s -> s.field("body").boost(1.0f)).build()); queries.add(new Query.Builder().exists(s -> s.field("body").boost(1.0f)).build());
} }
// 根据通道号过滤 // 根据通道号过滤
List<String> channelSerialNums = person.getChannelSerialNums(); List<String> channelSerialNums = person.getChannelSerialNums();
if (CollectionUtils.isNotEmpty(channelSerialNums)) { if (CollectionUtils.isNotEmpty(channelSerialNums)) {
queries.add(QueryBuilders.terms().field("channelSerialNum").terms((TermsQueryField) channelSerialNums).build()._toQuery()); queries.add(QueryBuilders.terms().field("channelSerialNum").terms(new TermsQueryField.Builder().value(channelSerialNums.stream().map(FieldValue::of).collect(Collectors.toList())).build()).build()._toQuery());
} }
// 根据监控点id进行过滤 // 根据监控点id进行过滤
List<Long> gateIdIn = person.getGateIdIn(); List<Long> gateIdIn = person.getGateIdIn();
if (CollectionUtils.isNotEmpty(gateIdIn)) { if (CollectionUtils.isNotEmpty(gateIdIn)) {
// boolQuery.filter(QueryBuilders.termsQuery("gateId", gateIdIn)); // boolQuery.filter(QueryBuilders.termsQuery("gateId", gateIdIn));
queries.add(QueryBuilders.terms().field("gateId").terms((TermsQueryField) gateIdIn).build()._toQuery()); ;
queries.add(QueryBuilders.terms().field("gateId").terms(new TermsQueryField.Builder().value(gateIdIn.stream().map(FieldValue::of).collect(Collectors.toList())).build()).build()._toQuery());
} }
// 根据人的ID进行过滤 // 根据人的ID进行过滤
if (StringUtils.isNotEmpty(person.getPersonUnid())) { if (StringUtils.isNotEmpty(person.getPersonUnid())) {
// boolQuery.filter(QueryBuilders.termQuery("personId", person.getPersonUnid())); // boolQuery.filter(QueryBuilders.termQuery("personId", person.getPersonUnid()));
queries.add(QueryBuilders.term().field("personId").value(person.getPersonUnid()).build()._toQuery()); queries.add(QueryBuilders.term().field("personId").value(FieldValue.of(person.getPersonUnid())).build()._toQuery());
} }
if (StringUtils.isNotBlank(person.getCompareDirection())) { if (StringUtils.isNotBlank(person.getCompareDirection())) {
// boolQuery.filter(QueryBuilders.term().field("direction")., person.getCompareDirection())); // boolQuery.filter(QueryBuilders.term().field("direction")., person.getCompareDirection()));
// QueryBuilders.terms().field("gateId").terms(Arrays.asList(person.getCompareDirection().split(","))) // QueryBuilders.terms().field("gateId").terms(Arrays.asList(person.getCompareDirection().split(",")))
queries.add(QueryBuilders.term().field("direction").value(person.getCompareDirection()).build()._toQuery()); queries.add(QueryBuilders.term().field("direction").value(FieldValue.of(person.getCompareDirection())).build()._toQuery());
} }
// RangeQuery.Builder builder = QueryBuilders.range().term(s -> s.field("counttime")); // RangeQuery.Builder builder = QueryBuilders.range().term(s -> s.field("counttime"));
...@@ -566,7 +550,7 @@ public class PersonService { ...@@ -566,7 +550,7 @@ public class PersonService {
// builder.size(matchResultSize); // builder.size(matchResultSize);
} }
SourceConfig sourceConfig = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build(); SourceConfig sourceConfig = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build();
log.debug("rid:{} poolId:{} 匹配时参数:{}", rid, poolId, scriptScoreQuery.toString()); // log.debug("rid:{} poolId:{} 匹配时参数:{}", rid, poolId, scriptScoreQuery.toString());
// KnnSearch knnQuery = getKnnSearch(feature, person, type); // KnnSearch knnQuery = getKnnSearch(feature, person, type);
// ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, type); // ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, type);
return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery._toQuery()).source(sourceConfig).size(matchResultSize).minScore(person.getBodyMinScore().doubleValue()).build(); return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery._toQuery()).source(sourceConfig).size(matchResultSize).minScore(person.getBodyMinScore().doubleValue()).build();
......
...@@ -179,7 +179,7 @@ public class PoolService { ...@@ -179,7 +179,7 @@ public class PoolService {
String poolId = requestVo.getPoolId(); String poolId = requestVo.getPoolId();
List<Person> personPool = requestVo.getPersonPool(); List<Person> personPool = requestVo.getPersonPool();
Integer updateType = requestVo.getUpdateType(); Integer updateType = requestVo.getUpdateType();
log.info("特征池修改操作开始:[{}],updateType:[{}]", poolId, updateType); // log.info("特征池修改操作开始:[{}],updateType:[{}]", poolId, updateType);
co.elastic.clients.elasticsearch.indices.ExistsRequest poolIdExists = new ExistsRequest.Builder().index(poolId).build(); co.elastic.clients.elasticsearch.indices.ExistsRequest poolIdExists = new ExistsRequest.Builder().index(poolId).build();
BooleanResponse poolIdExistsResponse = client.indices().exists(poolIdExists); BooleanResponse poolIdExistsResponse = client.indices().exists(poolIdExists);
if (!poolIdExistsResponse.value()) { if (!poolIdExistsResponse.value()) {
......
...@@ -3,9 +3,11 @@ server.port=12000 ...@@ -3,9 +3,11 @@ server.port=12000
spring.jackson.time-zone=GMT+8 spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
#es #es
spring.elasticsearch.rest.uris=http://182.92.184.40:9200 #spring.elasticsearch.rest.uris=http://182.92.184.40:9200
spring.elasticsearch.rest.uris=http://127.0.0.1:9200
spring.elasticsearch.rest.username=elastic spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=vion2021 spring.elasticsearch.rest.password=vion2021
spring.elasticsearch.rest.socketTimeout=5000
spring.elasticsearch.rest.ioThreadCount=20 spring.elasticsearch.rest.ioThreadCount=20
spring.elasticsearch.rest.maxConnTotal=100 spring.elasticsearch.rest.maxConnTotal=100
spring.elasticsearch.rest.maxConnPerRoute=20 spring.elasticsearch.rest.maxConnPerRoute=20
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!