Authored by zhaojun2

fix skn分词

... ... @@ -838,8 +838,21 @@ public class SearchExplainerService {
searchFieldResult.setFieldValue(document.get(analyzeFields.get(i).field).toString());
List<String> tokens = tokensGroupList.get(i);
searchFieldResult.setTokens(Arrays.asList(StringUtils.join(tokens, ";")));
List<String> matchTokens = keywordSearchAnalyzesMap.get(analyzeFields.get(i).search_analyzer).stream().filter(kt -> tokens.contains(kt.getTerm())).map(AnalyzeResponse.AnalyzeToken::getTerm).collect(Collectors.toList());
searchFieldResult.addAllMatchToken(matchTokens);
List<String> keywordtokens;
if (StringUtils.isBlank(analyzeFields.get(i).search_analyzer)) {
keywordtokens = Arrays.asList(keyword);
} else {
List<AnalyzeResponse.AnalyzeToken> keywordSearchAnalyzes = keywordSearchAnalyzesMap.get(analyzeFields.get(i).search_analyzer);
if (CollectionUtils.isNotEmpty(keywordSearchAnalyzes)) {
keywordtokens = keywordSearchAnalyzes.stream().map(AnalyzeResponse.AnalyzeToken::getTerm).collect(Collectors.toList());
} else {
keywordtokens = Arrays.asList(keyword);
}
}
searchFieldResult.setKeywordtokens(Arrays.asList(StringUtils.join(keywordtokens, ";")));
List<String> matchTokens = keywordtokens.stream().filter(t -> tokens.contains(t)).collect(Collectors.toList());
searchFieldResult.addAllMatchToken(Arrays.asList(StringUtils.join(matchTokens, ";")));
searchFieldResult.setMatchResult(CollectionUtils.isNotEmpty(matchTokens));
searchFieldResultList.add(searchFieldResult);
}
... ...
... ... @@ -20,6 +20,8 @@ public class SearchFieldResult implements Comparable<SearchFieldResult>{
private List<String> tokens;
private List<String> keywordtokens;
private List<String> matchTokens = new ArrayList<>();
private boolean matchResult;
... ... @@ -96,4 +98,12 @@ public class SearchFieldResult implements Comparable<SearchFieldResult>{
public void setMatchResult(boolean matchResult) {
this.matchResult = matchResult;
}
public List<String> getKeywordtokens() {
return keywordtokens;
}
public void setKeywordtokens(List<String> keywordtokens) {
this.keywordtokens = keywordtokens;
}
}
... ...