大型商城:检索服务

搭建检索服务的页面

引入thymeleaf依赖

首页index放入gulimall-search中template中,并修改静态资源的路径

修改网关,host:search.mall.com指向gulimall-search

将静态资源放入Nginx,修改配置文件后重启

调整页面跳转

首页三级分类点击跳转搜索页

首页三级分类中,点击分类跳转:http://search.mall.com/list.html?catalog3Id=( 静态文件 index/js/catalogLoader.js )

所以吧gulimall-search的index.html修改为list.html(controller中添加一个 getmapping("list.html")的方法 )

首页搜索框点击跳转搜索页

      <div class="header_form">
        <input id="searchText" type="text" placeholder="" />
        <span style="background: url(../staticindex/img/img_12.png) 0 -1px;"></span>
        <!--<button><i class="glyphicon"></i></button>-->
        <a href="javascript:search();" ><img src="/static/index/img/img_09.png"/></a>
      </div>

<script type="text/javascript">
  function search() {
      var keyword=$("#searchText").val()
      window.location.href="http://search.mall.com/list.html?keyword="+keyword;
  }
</script>

 检索查询参数模型分析抽取

新建一个实体类,用来封装页面所有可能传过来的查询参数

SearchParam

@Data
public class SearchParam {
    private String keyword; //页面传递过来的全文匹配关键字
    private Long catalog3Id; // 三级分类id
    /**
     *  sort = saleCount_asc/desc
     *  sort = skuPrice_asc/desc
     *  sort = hotScore_asc/sesc
     */
    private String sort;  //排序条件

    /**
     * 好多的过滤条件
     *  hasStock(是否有货),skuPrice(价格区间),brandId,catalog3Id,attrs
     *  hasStock = 0/1
     *  skuPrice = 1_500/_500/500_
     *  brandId = 1
     *  attrs = 2_5寸:6寸
     */
    private Integer hasStock;
    private String skuPrice;
    private List<Long> brangId;
    private List<String> attrs;
    private Integer pageNum; //页面
}

 

检索返回结果模型分析抽取

SearchResult

@Data
public class SearchResult {
    //查询到所有商品信息
    private List<SkuEsModel> products;
    /*
    分页信息
     */
    private Integer pageNum;   //当前页码
    private Long total; //总记录数
    private Integer totalPage;  //总页码

    private List<BrandVo> Brands;  //当前查询到的结果,所有涉及到的品牌
    private List<AttrsVo> attrs;  // 当前查询到的结果,所设计到的所有属性
    private List<CatalogVo> catalogs;


    // ==========以上是返回给页面的所有信息===========

    @Data
    public static class BrandVo{
        private Long brandId;
        private String brandName;
        private String BrandImg;
    }
    @Data
    public static class CatalogVo{
        private Long catalogId;
        private String catalogName;
    }
    @Data
    public static class AttrsVo{
        private Long attrId;
        private String brandname;
        private String brandImg;
    }
}

检索DSL测试

 

DSL查询部分与聚合部分,以及该部分的测试

 

SearchRequest的构建,检索,排序,分页,高亮测试,聚合,分析,封装

在 com.tinstu.gulimallseaech.service.Impl.MallSearchServiceImpl

(es的索引)

 

页面基本信息的渲染

 

页面数据的渲染,页面筛选条件渲染,页面份额数据的渲染,页面排序,页面排序字段回显,页面价格区间搜索

面包屑导航,条件删除与URL编码问题,条件筛选联动

gulimall-seaech / template 下的 list.html

 

阅读剩余
THE END