Commit 1c4ec01c by 姚冰

[chg] 去除强制刷新,搜索修改

1 parent 9998e1cb
......@@ -115,8 +115,8 @@ public class PersonService {
BoolQuery boolQuery = getSearchSourceCountBuilder(feature, person, 1);
query = boolQuery._toQuery();
} else {
ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, 1);
query = scriptScoreQuery._toQuery();
Query scriptScoreQuery = getScriptScoreQuery(feature, person, 1);
query = scriptScoreQuery;
}
SearchRequest request = new SearchRequest.Builder().index(Arrays.asList(indices)).ignoreUnavailable(true).aggregations("countId", countAggregation).size(0).query(query).build();
......@@ -312,7 +312,7 @@ public class PersonService {
return null;
}
BulkResponse bulk = client.bulk(new BulkRequest.Builder().index(poolId).operations(operationList).build());
poolService.refreshPool(poolId);
// poolService.refreshPool(poolId);
return bulk;
}
......@@ -413,16 +413,17 @@ public class PersonService {
return list.stream().map(x -> x.floatValue()).collect(Collectors.toList());
}
private ScriptScoreQuery getScriptScoreQuery(Double[] feature, Person person, int type) {
return new ScriptScoreQuery.Builder()
.query(getSearchSourceBuilder(feature, person, type)._toQuery())
.script(new Script.Builder()
.lang("painless")
.source("_score * 100")
.params("body", JsonData.of(0.0f))
.build())
.boost(1.0f)
.build();
private Query getScriptScoreQuery(Double[] feature, Person person, int type) {
return new Query.Builder().knn(getSearchSourceBuilder(feature, person, type)).build();
// return new ScriptScoreQuery.Builder()
// .query(getSearchSourceBuilder(feature, person, type)._toQuery())
// .script(new Script.Builder()
// .lang("painless")
// .source("_score * 100")
// .params("body", JsonData.of(0.0f))
// .build())
// .boost(1.0f)
// .build();
}
private BoolQuery getSearchSourceCountBuilder(Double[] feature, Person person, int type) {
......@@ -510,7 +511,7 @@ public class PersonService {
private SearchRequest getSearchRequest(String rid, String poolId, Integer matchResultSize, Double[] feature, Person person, int type, Boolean agg) {
// BoolQuery.Builder builder = getSearchSourceBuilder(feature, person, type);
ScriptScoreQuery scriptScoreQuery = getScriptScoreQuery(feature, person, 1);
Query scriptScoreQuery = getScriptScoreQuery(feature, person, 1);
if (agg) {
// AggregationBuilders.max("max_score", s -> s.field("_score").script(new Script.Builder().source("_score").build()));
// Aggregation aggregation = AggregationBuilders.max(s -> s.field("max_score").script(new Script.Builder().source("_score").build()));
......@@ -536,7 +537,7 @@ public class PersonService {
// 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();
return new SearchRequest.Builder().index(poolId).query(scriptScoreQuery).source(sourceConfig).size(matchResultSize).minScore(person.getBodyMinScore().doubleValue()/100).build();
}
private List<Person> match0(SearchRequest searchRequest, Boolean agg) throws Exception {
......@@ -580,7 +581,7 @@ public class PersonService {
})
.orElse(null));
p.setScore(item.score().floatValue());
p.setScore(item.score().floatValue() * 100);
p.setPersonPoolId(item.index());
persons.add(p);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!