Commit 6f6a25b2 by wenshuaiying

自动创建person时,使用匹配到的personid

1 parent 34af005f
...@@ -46,6 +46,12 @@ public class MainController { ...@@ -46,6 +46,12 @@ public class MainController {
return poolService.queryPool(requestVo); return poolService.queryPool(requestVo);
case MatchPerson: case MatchPerson:
ResponseVo matchPerson = personService.matchPerson(requestVo); ResponseVo matchPerson = personService.matchPerson(requestVo);
if (matchPerson.getMatchBodies() != null && matchPerson.getMatchBodies().size() > 0) {
requestVo.getPerson().setPersonId(matchPerson.getMatchBodies().get(0).getPersonId());
} else if(matchPerson.getMatchPersons() != null && matchPerson.getMatchPersons().size() > 0) {
requestVo.getPerson().setPersonId(matchPerson.getMatchPersons().get(0).getPersonId());
}
poolService.asyncModifyPool(requestVo.getPersonPoolId(), requestVo.getPerson()); poolService.asyncModifyPool(requestVo.getPersonPoolId(), requestVo.getPerson());
return matchPerson; return matchPerson;
case UpdatePerson: case UpdatePerson:
......
...@@ -56,6 +56,7 @@ import java.util.stream.Stream; ...@@ -56,6 +56,7 @@ import java.util.stream.Stream;
@Slf4j @Slf4j
public class PersonService { 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"};
public static final SourceConfig SOURCE_CONFIG = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build();
@Resource @Resource
private ElasticsearchClient client; private ElasticsearchClient client;
@Resource @Resource
...@@ -577,14 +578,13 @@ public class PersonService { ...@@ -577,14 +578,13 @@ public class PersonService {
// BoolQuery.Builder builder = getSearchSourceBuilder(feature, person, type); // BoolQuery.Builder builder = getSearchSourceBuilder(feature, person, type);
Query scriptScoreQuery = getScriptScoreQuery(feature, person, type); Query scriptScoreQuery = getScriptScoreQuery(feature, person, type);
SourceConfig sourceConfig = new SourceConfig.Builder().filter(s -> s.includes(Arrays.asList(FETCH_SOURCE))).build();
double minScore = 0.0; double minScore = 0.0;
if (type == 0) { if (type == 0) {
minScore = person.getFaceMinScore().doubleValue()/100; minScore = person.getFaceMinScore().doubleValue()/100;
} else if (type == 1) { } else if (type == 1) {
minScore = person.getBodyMinScore().doubleValue()/100; minScore = person.getBodyMinScore().doubleValue()/100;
} }
return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(sourceConfig) return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(SOURCE_CONFIG)
.size(matchResultSize) .size(matchResultSize)
.minScore(minScore) .minScore(minScore)
.timeout("50ms") .timeout("50ms")
...@@ -640,7 +640,7 @@ public class PersonService { ...@@ -640,7 +640,7 @@ public class PersonService {
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("match0 excepton", e); log.error(" n", e);
} }
return persons; return persons;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!