Authored by wangnan

修改field权重值

... ... @@ -20,6 +20,16 @@ import java.util.*;
@Service
public class SearchServiceHelper {
//store_name^1000,store_english_name^1000,store_name_tc^1000,store_first^500,address_full^300,des^100
public final static Map<String, Float> boostMap = new HashMap<String, Float>() {{
put("store_name", 1000f);
put("store_english_name", 1000f);
put("store_name_tc", 1000f);
put("store_first", 500f);
put("address_full", 300f);
put("des", 100f);
}};
/**
* 构造距离查询范围
... ... @@ -107,7 +117,9 @@ public class SearchServiceHelper {
if (paramMap.containsKey("queryField") && StringUtils.isNotBlank(paramMap.get("queryField"))) {
String[] fields = paramMap.get("queryField").split(",");
for (int i = 0; i < fields.length; i++) {
queryBuilder.field(fields[i]);
if (boostMap.containsKey(fields[i])) {
queryBuilder.field(fields[i], boostMap.get(fields[i]));
}
}
} else {
//设置searchfield和权重
... ...
... ... @@ -16,7 +16,7 @@ search.use.cache=true
search.multiMatchQuery.type=CROSS_FIELDS
search.suggest.field=suggest^1
search.default.field.bizArea=name^300,english_name^200,name_tc^200,des^100
search.default.field.store=store_name^300,store_english_name^200,store_name_tc^200,store_first^200,address_full^200,des^100
search.default.field.store=store_name^1000,store_english_name^1000,store_name_tc^1000,store_first^500,address_full^300,des^100
search.default.field.topic=title^300,title_tc^200
search.default.field.line=title^300,title_tc^200
search.default.field.comment=description^300
... ...