Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
VVAS-Match
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7ebc9871
authored
Sep 09, 2024
by
姚冰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[chg] 部分条件修改,去除部分日志,添加超时参数
1 parent
113515d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
28 deletions
src/main/java/com/viontech/match/service/PersonService.java
src/main/java/com/viontech/match/service/PoolService.java
src/main/resources/application-option.properties
src/main/java/com/viontech/match/service/PersonService.java
View file @
7ebc987
...
...
@@ -154,7 +154,7 @@ public class PersonService {
if
(
poolId
!=
null
)
{
poolIds
.
add
(
poolId
);
}
log
.
info
(
"人员匹配操作开始,PoolIds:[{}],rid:{}"
,
poolIds
,
rid
);
//
log.info("人员匹配操作开始,PoolIds:[{}],rid:{}", poolIds, rid);
long
startTime
=
System
.
currentTimeMillis
();
try
{
for
(
String
id
:
poolIds
)
{
...
...
@@ -162,8 +162,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
{
...
...
@@ -374,7 +374,7 @@ public class PersonService {
matchResult
.
addAll
(
match0
(
searchRequest
,
agg
));
}
}
else
{
log
.
info
(
"no face feature"
);
//
log.info("no face feature");
}
}
...
...
@@ -452,51 +452,35 @@ public class PersonService {
// .build()._toQuery();
// queries.add(query);
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
){
// 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").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
());
}
// 根据通道号过滤
List
<
String
>
channelSerialNums
=
person
.
getChannelSerialNums
();
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进行过滤
List
<
Long
>
gateIdIn
=
person
.
getGateIdIn
();
if
(
CollectionUtils
.
isNotEmpty
(
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进行过滤
if
(
StringUtils
.
isNotEmpty
(
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
()))
{
// boolQuery.filter(QueryBuilders.term().field("direction")., person.getCompareDirection()));
// 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"));
...
...
@@ -566,7 +550,7 @@ public class PersonService {
// builder.size(matchResultSize);
}
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);
// ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, type);
return
new
SearchRequest
.
Builder
().
index
(
poolId
).
query
(
scriptScoreQuery
.
_toQuery
()).
source
(
sourceConfig
).
size
(
matchResultSize
).
minScore
(
person
.
getBodyMinScore
().
doubleValue
()).
build
();
...
...
src/main/java/com/viontech/match/service/PoolService.java
View file @
7ebc987
...
...
@@ -179,7 +179,7 @@ public class PoolService {
String
poolId
=
requestVo
.
getPoolId
();
List
<
Person
>
personPool
=
requestVo
.
getPersonPool
();
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
();
BooleanResponse
poolIdExistsResponse
=
client
.
indices
().
exists
(
poolIdExists
);
if
(!
poolIdExistsResponse
.
value
())
{
...
...
src/main/resources/application-option.properties
View file @
7ebc987
...
...
@@ -3,9 +3,11 @@ server.port=12000
spring.jackson.time-
zone
=
GMT+8
spring.jackson.date-
format
=
yyyy-MM-dd HH:mm:ss
#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.password
=
vion2021
spring.elasticsearch.rest.socketTimeout
=
5000
spring.elasticsearch.rest.ioThreadCount
=
20
spring.elasticsearch.rest.maxConnTotal
=
100
spring.elasticsearch.rest.maxConnPerRoute
=
20
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment