Authored by Gino Zhang

Merge branch 'zf_explain_skn' into test

... ... @@ -145,12 +145,19 @@ public class SearchExplainerService {
List<String> sortedSearchFields = getSortedSearchFields();
logger.info("Get the search fields. fields: {}", sortedSearchFields);
// TODO: 这里先只取search_analyzer是ik_complex的 对于productSkn_ansj进行忽略处理
FieldDesc maxBoostField = fieldDescMap.get(sortedSearchFields.get(0));
Assert.notNull(maxBoostField.search_analyzer, "for " + sortedSearchFields.get(0));
for (FieldWithBoost fieldWithBoost : this.localMutilFieldWithBoostList) {
resultList.add(showSingleField(fieldWithBoost, document.get(fieldWithBoost.fieldName), fieldDescMap.get(fieldWithBoost.fieldName)));
FieldDesc fieldDesc = fieldDescMap.get(fieldWithBoost.fieldName);
Assert.notNull(fieldDesc, "for " + fieldWithBoost.fieldName);
if(maxBoostField.search_analyzer.equals(fieldDesc.search_analyzer)){
resultList.add(showSingleField(fieldWithBoost, document.get(fieldWithBoost.fieldName), fieldDesc));
}
}
// 5. 对query的关键字进行分词
List<String> searchTokens = StringUtils.isNotEmpty(keyword) ? getKeyWordAnalyzerResult(fieldDescMap.get(sortedSearchFields.get(0)), keyword) : null;
List<String> searchTokens = StringUtils.isNotEmpty(keyword) ? getKeyWordAnalyzerResult(maxBoostField, keyword) : null;
// 6. 处理匹配结果。匹配结果暂时只考虑是cross_fields的 并且所有字段的search_analyzer都是ik_complex
if(CollectionUtils.isNotEmpty(searchTokens)){
... ... @@ -175,7 +182,7 @@ public class SearchExplainerService {
}
private SearchFieldResult showSingleField(FieldWithBoost fieldWithBoost, Object fieldValue, FieldDesc fieldDesc) throws Exception {
Assert.notNull(fieldDesc, "for " + fieldWithBoost.fieldName);
SearchFieldResult searchFieldResult = new SearchFieldResult();
searchFieldResult.setFieldName(fieldWithBoost.fieldName);
searchFieldResult.setBoost(fieldWithBoost.boost);
... ...