Commit 1c4ec01c by 姚冰

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

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