Authored by Gino Zhang

sknShowToken接口增加匹配结果项

... ... @@ -160,15 +160,21 @@ public class SearchExplainerService {
List<String> searchTokens = StringUtils.isNotEmpty(keyword) ? getKeyWordAnalyzerResult(maxBoostField, keyword) : null;
// 6. 处理匹配结果。匹配结果暂时只考虑是cross_fields的 并且所有字段的search_analyzer都是ik_complex
boolean queryMatchResult = true;
if(CollectionUtils.isNotEmpty(searchTokens)){
for (String searchToken : searchTokens){
boolean isTokenMatched = false;
for(SearchFieldResult searchFieldResult : resultList){
if(searchFieldResult.getTokens().contains(searchToken)){
searchFieldResult.addMatchToken(searchToken);
searchFieldResult.setMatchResult(true);
isTokenMatched = true;
break;
}
}
// 只有所有token都匹配成功才返回true
queryMatchResult = queryMatchResult && isTokenMatched;
}
}
... ... @@ -176,6 +182,7 @@ public class SearchExplainerService {
map.put("message", "show skn tokens");
map.put("data", resultList);
map.put("searchTokens", searchTokens);
map.put("queryMatchResult", queryMatchResult);
logger.info("End to show skn tokens. skn={}, keyword={}, cost={}.", skn, keyword, System.currentTimeMillis() - start);
return map;
... ...