检索服务创建
------------恢复内容开始------------
关闭thymeleaf 缓存

创建对应的vo
我们需要检索数据库中的相关商品信息 我们需要提交相关的检索条件 为了统一的管理提交的数据
我们需要创建一个vo来封装信息
@Data public class SearchParam { private String keyword;//页面传递查询全文的关键字 private Long catalog3Id;//三级分类id /*sort=saleCount_asc/desc sort=skuPrice_asc/desc sort=hotPrice_asc/desc * */ private String sort;//排序条件 //查询筛选条件 hasStock=0/1 private Integer hasStock;//是否只显示有货 //brandId=1&brandId=2 private List<Long> brandId;//按照品牌来查询 可以多选 //skuPrice=200_300 skuPrice=_300最大如果左边为空 默认给个0 skuPrice=200_最小 右边为空 无上限 private String skuPrice;//价格区间查询 //针对不同的属性 attrs:1_苹果:6.5寸 private List<String> attrs;//按照属性信息 进行筛选 private Integer pageNum; }
我们根据基本的检索条件封装对应的DSL语句
关键字查询 模糊匹配
过滤(分类,品牌,属性,价格区间)
排序
分页
高亮 GET /product/_search { "query": { "bool": { "must": [ { "match": { "subTitle": "华为" } } ], "filter": [ { "term": { "catalogId": "225" } }, { "terms": { "brandId": [ "12", "17" ] } }, { "range": { "skuPrice": { "gte": 10, "lte": 20000 } } } ] } },"sort": [ { "skuPrice": { "order": "desc" } } ],"from": 0 ,"size": 20 ,"highlight": { "fields": {"subTitle": {}} ,"pre_tags": "<b style='color:red'>" ,"post_tags": "</b>" } }
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号