Authored by Gino Zhang

搜索无结果或搜索结果过少优化 suggestion增加weight进行排序

1 package com.yoho.search.service.restapi; 1 package com.yoho.search.service.restapi;
2 2
3 -import java.util.HashMap;  
4 -import java.util.Map;  
5 -  
6 -import javax.servlet.http.HttpServletRequest;  
7 - 3 +import com.alibaba.fastjson.JSONObject;
  4 +import com.yoho.search.service.servicenew.IProductListService;
  5 +import com.yoho.search.service.utils.HttpServletRequestUtils;
  6 +import com.yoho.search.service.vo.SearchApiResult;
8 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.stereotype.Controller; 8 import org.springframework.stereotype.Controller;
10 import org.springframework.web.bind.annotation.RequestBody; 9 import org.springframework.web.bind.annotation.RequestBody;
@@ -12,11 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -12,11 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
12 import org.springframework.web.bind.annotation.RequestMethod; 11 import org.springframework.web.bind.annotation.RequestMethod;
13 import org.springframework.web.bind.annotation.ResponseBody; 12 import org.springframework.web.bind.annotation.ResponseBody;
14 13
15 -import com.alibaba.fastjson.JSON;  
16 -import com.alibaba.fastjson.JSONObject;  
17 -import com.yoho.search.service.servicenew.IProductListService;  
18 -import com.yoho.search.service.utils.HttpServletRequestUtils;  
19 -import com.yoho.search.service.vo.SearchApiResult; 14 +import javax.servlet.http.HttpServletRequest;
  15 +import java.util.HashMap;
  16 +import java.util.Map;
20 17
21 @Controller 18 @Controller
22 public class ProductListController { 19 public class ProductListController {
@@ -141,7 +141,7 @@ public class ProductListServiceImpl implements IProductListService { @@ -141,7 +141,7 @@ public class ProductListServiceImpl implements IProductListService {
141 searchParam.setFiter(QueryBuilders.rangeQuery("count").gte(10)); //TODO: 针对不同的搜索条件选择不同的count 141 searchParam.setFiter(QueryBuilders.rangeQuery("count").gte(10)); //TODO: 针对不同的搜索条件选择不同的count
142 142
143 List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>(); 143 List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>();
144 - //sortBuilders.add(SortBuilders.fieldSort("weight").order(SortOrder.DESC)); 144 + sortBuilders.add(SortBuilders.fieldSort("weight").order(SortOrder.DESC));
145 sortBuilders.add(SortBuilders.fieldSort("count").order(SortOrder.DESC)); 145 sortBuilders.add(SortBuilders.fieldSort("count").order(SortOrder.DESC));
146 searchParam.setSortBuilders(sortBuilders); 146 searchParam.setSortBuilders(sortBuilders);
147 147