parent
7e3d927ec9
commit
642348c09e
@ -0,0 +1,19 @@
|
|||||||
|
package com.xjs.mall.search.service;
|
||||||
|
|
||||||
|
import com.xjs.mall.search.vo.SearchParam;
|
||||||
|
import com.xjs.mall.search.vo.SearchResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-05-11
|
||||||
|
*/
|
||||||
|
public interface MallSearchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param searchParam 检索的所有参数
|
||||||
|
* @return obj
|
||||||
|
*/
|
||||||
|
SearchResult search(SearchParam searchParam);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package com.xjs.mall.search.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* es 检索条件实体
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-05-11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SearchParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页面传递的全文匹配关键字
|
||||||
|
*/
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 三级分类id
|
||||||
|
*/
|
||||||
|
private Long catalog3Id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序条件 saleCount_asc/desc skuPrice_asc/desc hotScore_asc/desc
|
||||||
|
*/
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤条件
|
||||||
|
* hasStock(是否有货) 、skuPrice区间 、 brandId 、 catalog3Id 、 attrs
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否只显示有货(0:无库存 1:有库存)
|
||||||
|
*/
|
||||||
|
private Integer hasStock = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 价格区间查询
|
||||||
|
*/
|
||||||
|
private String skuPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌id
|
||||||
|
*/
|
||||||
|
private List<Long> brandId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照属性进行筛选
|
||||||
|
*/
|
||||||
|
private List<String> attrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 页码
|
||||||
|
*/
|
||||||
|
private Integer pageNum = 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
package com.xjs.mall.search.vo;
|
||||||
|
|
||||||
|
import com.xjs.mall.to.es.SkuEsModel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检索响应信息实体
|
||||||
|
*
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-05-11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SearchResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询到的所有商品信息
|
||||||
|
*/
|
||||||
|
private List<SkuEsModel> products;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前页面
|
||||||
|
*/
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总数
|
||||||
|
*/
|
||||||
|
private Long total;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总页码
|
||||||
|
*/
|
||||||
|
private Integer totalPages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前结果查询的所有品牌
|
||||||
|
*/
|
||||||
|
private List<BrandVo> brands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前结果查询的所有属性
|
||||||
|
*/
|
||||||
|
private List<AttrVo> attrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前结果查询的所有分类
|
||||||
|
*/
|
||||||
|
private List<CatalogVo> catalogs;
|
||||||
|
|
||||||
|
private List<Integer> pageNavs;
|
||||||
|
|
||||||
|
//================以上是返回给页面的所有信息=========================
|
||||||
|
|
||||||
|
/* 面包屑导航数据 */
|
||||||
|
private List<NavVo> navs;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class NavVo {
|
||||||
|
private String navName;
|
||||||
|
private String navValue;
|
||||||
|
private String link;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class BrandVo {
|
||||||
|
/**
|
||||||
|
* 品牌id
|
||||||
|
*/
|
||||||
|
private Long brandId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌名
|
||||||
|
*/
|
||||||
|
private String brandName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌logo
|
||||||
|
*/
|
||||||
|
private String brandImg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class AttrVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性id
|
||||||
|
*/
|
||||||
|
private Long attrId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性名
|
||||||
|
*/
|
||||||
|
private String attrName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private List<String> attrValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class CatalogVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类ID
|
||||||
|
*/
|
||||||
|
private Long catalogId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类名称
|
||||||
|
*/
|
||||||
|
private String catalogName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"must": [ {"match": { "skuTitle": "华为" }} ],
|
||||||
|
"filter": [
|
||||||
|
{ "term": { "catalogId": "225" } },
|
||||||
|
{ "terms": {"brandId": [ "2"] } },
|
||||||
|
{ "term": { "hasStock": "false"} },
|
||||||
|
{
|
||||||
|
"range": {
|
||||||
|
"skuPrice": {
|
||||||
|
"gte": 1000,
|
||||||
|
"lte": 7000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nested": {
|
||||||
|
"path": "attrs",
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"must": [
|
||||||
|
{
|
||||||
|
"term": { "attrs.attrId": { "value": "6"} }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sort": [ {"skuPrice": {"order": "desc" } } ],
|
||||||
|
"from": 0,
|
||||||
|
"size": 5,
|
||||||
|
"highlight": {
|
||||||
|
"fields": {"skuTitle": {}},
|
||||||
|
"pre_tags": "<b style='color:red'>",
|
||||||
|
"post_tags": "</b>"
|
||||||
|
},
|
||||||
|
"aggs": {
|
||||||
|
"brandAgg": {
|
||||||
|
"terms": {
|
||||||
|
"field": "brandId",
|
||||||
|
"size": 10
|
||||||
|
},
|
||||||
|
"aggs": {
|
||||||
|
"brandNameAgg": {
|
||||||
|
"terms": {
|
||||||
|
"field": "brandName",
|
||||||
|
"size": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"brandImgAgg": {
|
||||||
|
"terms": {
|
||||||
|
"field": "brandImg",
|
||||||
|
"size": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"catalogAgg":{
|
||||||
|
"terms": {
|
||||||
|
"field": "catalogId",
|
||||||
|
"size": 10
|
||||||
|
},
|
||||||
|
"aggs": {
|
||||||
|
"catalogNameAgg": {
|
||||||
|
"terms": {
|
||||||
|
"field": "catalogName",
|
||||||
|
"size": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"attrs":{
|
||||||
|
"nested": {"path": "attrs" },
|
||||||
|
"aggs": {
|
||||||
|
"attrIdAgg": {
|
||||||
|
"terms": {
|
||||||
|
"field": "attrs.attrId",
|
||||||
|
"size": 10
|
||||||
|
},
|
||||||
|
"aggs": {
|
||||||
|
"attrNameAgg": {
|
||||||
|
"terms": {
|
||||||
|
"field": "attrs.attrName",
|
||||||
|
"size": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue