初始化提交
This commit is contained in:
		@@ -0,0 +1,12 @@
 | 
			
		||||
package com.tuling.tulingmall.search;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.SpringApplication;
 | 
			
		||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
 | 
			
		||||
 | 
			
		||||
@SpringBootApplication
 | 
			
		||||
public class MallSearchApplication {
 | 
			
		||||
 | 
			
		||||
    public static void main(String[] args) {
 | 
			
		||||
        SpringApplication.run(MallSearchApplication.class, args);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,41 @@
 | 
			
		||||
package com.tuling.tulingmall.search.config;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@author 图灵学院-白起老师
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
import org.apache.http.HttpHost;
 | 
			
		||||
import org.apache.http.auth.AuthScope;
 | 
			
		||||
import org.apache.http.auth.UsernamePasswordCredentials;
 | 
			
		||||
import org.apache.http.client.CredentialsProvider;
 | 
			
		||||
import org.apache.http.impl.client.BasicCredentialsProvider;
 | 
			
		||||
import org.elasticsearch.client.RestClient;
 | 
			
		||||
import org.elasticsearch.client.RestClientBuilder;
 | 
			
		||||
import org.elasticsearch.client.RestHighLevelClient;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
 | 
			
		||||
@Configuration
 | 
			
		||||
public class ElasticSearchConfig {
 | 
			
		||||
 | 
			
		||||
    @Bean
 | 
			
		||||
    public RestHighLevelClient restHighLevelClient(){
 | 
			
		||||
//        RestHighLevelClient client = new RestHighLevelClient(
 | 
			
		||||
//                RestClient.builder(
 | 
			
		||||
//                       new HttpHost("192.168.21.130", 9200, "http"),
 | 
			
		||||
//                        new HttpHost("192.168.21.131", 9200, "http"),
 | 
			
		||||
//                        new HttpHost("192.168.21.132", 9200, "http")));
 | 
			
		||||
 | 
			
		||||
        RestClientBuilder builder=RestClient.builder(
 | 
			
		||||
                new HttpHost("192.168.65.110", 9200, "http"),
 | 
			
		||||
                new HttpHost("192.168.65.113", 9200, "http"),
 | 
			
		||||
                new HttpHost("192.168.65.219", 9200, "http"));
 | 
			
		||||
        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
 | 
			
		||||
        credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "123456"));
 | 
			
		||||
        builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider));
 | 
			
		||||
        RestHighLevelClient client = new RestHighLevelClient( builder);
 | 
			
		||||
        return client;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,13 @@
 | 
			
		||||
package com.tuling.tulingmall.search.config;
 | 
			
		||||
 | 
			
		||||
import org.mybatis.spring.annotation.MapperScan;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MyBatis配置类
 | 
			
		||||
 * Created on 2019/4/8.
 | 
			
		||||
 */
 | 
			
		||||
@Configuration
 | 
			
		||||
@MapperScan({"com.tuling.tulingmall.search.dao"})
 | 
			
		||||
public class MyBatisConfig {
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,38 @@
 | 
			
		||||
package com.tuling.tulingmall.search.config;
 | 
			
		||||
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import springfox.documentation.builders.ApiInfoBuilder;
 | 
			
		||||
import springfox.documentation.builders.PathSelectors;
 | 
			
		||||
import springfox.documentation.builders.RequestHandlerSelectors;
 | 
			
		||||
import springfox.documentation.service.ApiInfo;
 | 
			
		||||
import springfox.documentation.spi.DocumentationType;
 | 
			
		||||
import springfox.documentation.spring.web.plugins.Docket;
 | 
			
		||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Swagger2API文档的配置
 | 
			
		||||
 * Created on 2018/4/26.
 | 
			
		||||
 */
 | 
			
		||||
@Configuration
 | 
			
		||||
@EnableSwagger2
 | 
			
		||||
public class Swagger2Config {
 | 
			
		||||
    @Bean
 | 
			
		||||
    public Docket createRestApi(){
 | 
			
		||||
        return new Docket(DocumentationType.SWAGGER_2)
 | 
			
		||||
                .apiInfo(apiInfo())
 | 
			
		||||
                .select()
 | 
			
		||||
                .apis(RequestHandlerSelectors.basePackage("com.macro.mall.search.controller"))
 | 
			
		||||
                .paths(PathSelectors.any())
 | 
			
		||||
                .build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private ApiInfo apiInfo() {
 | 
			
		||||
        return new ApiInfoBuilder()
 | 
			
		||||
                .title("mall搜索系统")
 | 
			
		||||
                .description("mall搜索模块")
 | 
			
		||||
                .contact("tuling")
 | 
			
		||||
                .version("1.0")
 | 
			
		||||
                .build();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,124 @@
 | 
			
		||||
package com.tuling.tulingmall.search.controller;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@author 图灵学院-白起老师
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.TreeMap;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.GetMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.User;
 | 
			
		||||
import com.tuling.tulingmall.search.service.EsClientSearchService;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
public class EsClientProductController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EsClientSearchService esClientSearchService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //创建索引库
 | 
			
		||||
    @GetMapping("/createIndex")
 | 
			
		||||
    public boolean createIndex()  throws IOException{
 | 
			
		||||
        System.out.println("创建索引====");
 | 
			
		||||
        return esClientSearchService.createIndex("es_test_index");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //判断索引库是否存在
 | 
			
		||||
    @GetMapping("/isExitIndex")
 | 
			
		||||
    public boolean isExitIndex() throws IOException {
 | 
			
		||||
        return esClientSearchService.isExit("es_test_index");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //删除索引库
 | 
			
		||||
    @GetMapping("/deleteIndex")
 | 
			
		||||
    public boolean deleteIndex() throws IOException {
 | 
			
		||||
        return esClientSearchService.delete("es_test_index");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //添加文档
 | 
			
		||||
    @GetMapping("/addDocument")
 | 
			
		||||
    public boolean addDocument() throws IOException {
 | 
			
		||||
        return  esClientSearchService.addDocument("es_test_index", "1", new User("jack",20,"杰克船长"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
     //判断文档是否存在
 | 
			
		||||
    @GetMapping("/isDocumentExit")
 | 
			
		||||
    public boolean isDocumentExit(String index, String id) throws IOException {
 | 
			
		||||
        return esClientSearchService.isdocuexit("es_test_index", "1");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //根据id获取文档
 | 
			
		||||
    @GetMapping("/getDoucumment")
 | 
			
		||||
    public String getDoucumment(String index, String id) throws IOException {
 | 
			
		||||
        return esClientSearchService.getDoucumment("es_test_index", "1");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //更新文档信息
 | 
			
		||||
    @GetMapping("/updateDocument")
 | 
			
		||||
    public boolean updateDocument(Object object, String index, String id) throws IOException {
 | 
			
		||||
           return esClientSearchService.updateDocument(new User("白起",18,"白起老师"),"es_test_index", "1");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //删除文档
 | 
			
		||||
    @GetMapping("/deleteDocument")
 | 
			
		||||
    public boolean deleteDocument(String index, String id) throws IOException{
 | 
			
		||||
        return esClientSearchService.deleteDocument("es_test_index", "1");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //批量添加
 | 
			
		||||
    @GetMapping("/addMoreDocument")
 | 
			
		||||
    public boolean addMoreDocument() throws IOException{
 | 
			
		||||
 | 
			
		||||
        User u1 = new User("jack",20,"杰克船长");
 | 
			
		||||
        User u2 = new User("rose",21,"肉丝船长");
 | 
			
		||||
        User u3 = new User("tom",22,"汤姆船长");
 | 
			
		||||
        List<Object> list = new ArrayList<>();
 | 
			
		||||
        list.add(u1);
 | 
			
		||||
        list.add(u2);
 | 
			
		||||
        list.add(u3);
 | 
			
		||||
        return esClientSearchService.addmoredocument(list,"es_test_index", "1");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/termQuery")
 | 
			
		||||
    public List<Map<String,Object>> termQuery() throws IOException {
 | 
			
		||||
 | 
			
		||||
        TreeMap<String, Object> map = new TreeMap<>();
 | 
			
		||||
        map.put("name", "jack");
 | 
			
		||||
       return esClientSearchService.termQuery("es_test_index",map , 2, 0, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/matchQuery")
 | 
			
		||||
    public List<Map<String,Object>> matchQuery() throws IOException {
 | 
			
		||||
        TreeMap<String, Object> map = new TreeMap<>();
 | 
			
		||||
        map.put("name", "rose");
 | 
			
		||||
 | 
			
		||||
        return esClientSearchService.matchQuery("es_test_index",map , 2, 0, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @GetMapping("/boolmustQuery")
 | 
			
		||||
    public List<Map<String,Object>> boolmustQuery() throws IOException {
 | 
			
		||||
 | 
			
		||||
        TreeMap<String, Object> map = new TreeMap<>();
 | 
			
		||||
        map.put("name", "jack");
 | 
			
		||||
        map.put("age",20 );
 | 
			
		||||
        return esClientSearchService.boolmustQuery("es_test_index",map , 2, 0,true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,115 @@
 | 
			
		||||
//package com.tuling.tulingmall.search.controller;
 | 
			
		||||
//
 | 
			
		||||
//
 | 
			
		||||
//import com.tuling.tulingmall.common.api.CommonPage;
 | 
			
		||||
//import com.tuling.tulingmall.common.api.CommonResult;
 | 
			
		||||
//import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
//import com.tuling.tulingmall.search.domain.EsProductRelatedInfo;
 | 
			
		||||
//import com.tuling.tulingmall.search.service.EsProductService;
 | 
			
		||||
//import io.swagger.annotations.Api;
 | 
			
		||||
//import io.swagger.annotations.ApiImplicitParam;
 | 
			
		||||
//import io.swagger.annotations.ApiOperation;
 | 
			
		||||
//import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
//import org.springframework.data.domain.Page;
 | 
			
		||||
//import org.springframework.stereotype.Controller;
 | 
			
		||||
//import org.springframework.web.bind.annotation.*;
 | 
			
		||||
//
 | 
			
		||||
//import java.util.List;
 | 
			
		||||
//
 | 
			
		||||
///**
 | 
			
		||||
// * 搜索商品管理Controller
 | 
			
		||||
// * Created on 2018/6/19.
 | 
			
		||||
// */
 | 
			
		||||
//@Controller
 | 
			
		||||
//@Api(tags = "EsProductController", description = "搜索商品管理")
 | 
			
		||||
//@RequestMapping("/esProduct")
 | 
			
		||||
//public class EsProductController {
 | 
			
		||||
//    @Autowired
 | 
			
		||||
//    private EsProductService esProductService;
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.ResponseBody;
 | 
			
		||||
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
 | 
			
		||||
//    @ApiOperation(value = "导入所有数据库中商品到ES")
 | 
			
		||||
//    @RequestMapping(value = "/importAll", method = RequestMethod.POST)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<Integer> importAllList() {
 | 
			
		||||
//        int count = esProductService.importAll();
 | 
			
		||||
//        return CommonResult.success(count);
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "根据id删除商品")
 | 
			
		||||
//    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<Object> delete(@PathVariable Long id) {
 | 
			
		||||
//        esProductService.delete(id);
 | 
			
		||||
//        return CommonResult.success(null);
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "根据id批量删除商品")
 | 
			
		||||
//    @RequestMapping(value = "/delete/batch", method = RequestMethod.POST)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<Object> delete(@RequestParam("ids") List<Long> ids) {
 | 
			
		||||
//        esProductService.delete(ids);
 | 
			
		||||
//        return CommonResult.success(null);
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "根据id创建商品")
 | 
			
		||||
//    @RequestMapping(value = "/create/{id}", method = RequestMethod.POST)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<EsProduct> create(@PathVariable Long id) {
 | 
			
		||||
//        EsProduct esProduct = esProductService.create(id);
 | 
			
		||||
//        if (esProduct != null) {
 | 
			
		||||
//            return CommonResult.success(esProduct);
 | 
			
		||||
//        } else {
 | 
			
		||||
//            return CommonResult.failed();
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "简单搜索")
 | 
			
		||||
//    @RequestMapping(value = "/search/simple", method = RequestMethod.POST)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<CommonPage<EsProduct>> search(@RequestParam(required = false) String keyword,
 | 
			
		||||
//                                                      @RequestParam(required = false, defaultValue = "0") Integer pageNum,
 | 
			
		||||
//                                                      @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
 | 
			
		||||
//        Page<EsProduct> esProductPage = esProductService.search(keyword, pageNum, pageSize);
 | 
			
		||||
//        return CommonResult.success(CommonPage.restPage(esProductPage));
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "综合搜索、筛选、排序")
 | 
			
		||||
//    @ApiImplicitParam(name = "sort", value = "排序字段:0->按相关度;1->按新品;2->按销量;3->价格从低到高;4->价格从高到低",
 | 
			
		||||
//            defaultValue = "0", allowableValues = "0,1,2,3,4", paramType = "query", dataType = "integer")
 | 
			
		||||
//    @RequestMapping(value = "/search", method = RequestMethod.GET)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<CommonPage<EsProduct>> search(@RequestParam(required = false) String keyword,
 | 
			
		||||
//                                                      @RequestParam(required = false) Long brandId,
 | 
			
		||||
//                                                      @RequestParam(required = false) Long productCategoryId,
 | 
			
		||||
//                                                      @RequestParam(required = false, defaultValue = "0") Integer pageNum,
 | 
			
		||||
//                                                      @RequestParam(required = false, defaultValue = "5") Integer pageSize,
 | 
			
		||||
//                                                      @RequestParam(required = false, defaultValue = "0") Integer sort) {
 | 
			
		||||
//        Page<EsProduct> esProductPage = esProductService.search(keyword, brandId, productCategoryId, pageNum, pageSize, sort);
 | 
			
		||||
//        return CommonResult.success(CommonPage.restPage(esProductPage));
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "根据商品id推荐商品")
 | 
			
		||||
//    @RequestMapping(value = "/recommend/{id}", method = RequestMethod.GET)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<CommonPage<EsProduct>> recommend(@PathVariable Long id,
 | 
			
		||||
//                                                         @RequestParam(required = false, defaultValue = "0") Integer pageNum,
 | 
			
		||||
//                                                         @RequestParam(required = false, defaultValue = "5") Integer pageSize) {
 | 
			
		||||
//        Page<EsProduct> esProductPage = esProductService.recommend(id, pageNum, pageSize);
 | 
			
		||||
//        return CommonResult.success(CommonPage.restPage(esProductPage));
 | 
			
		||||
//    }
 | 
			
		||||
//
 | 
			
		||||
//    @ApiOperation(value = "获取搜索的相关品牌、分类及筛选属性")
 | 
			
		||||
//    @RequestMapping(value = "/search/relate", method = RequestMethod.GET)
 | 
			
		||||
//    @ResponseBody
 | 
			
		||||
//    public CommonResult<EsProductRelatedInfo> searchRelatedInfo(@RequestParam(required = false) String keyword) {
 | 
			
		||||
//        EsProductRelatedInfo productRelatedInfo = esProductService.searchRelatedInfo(keyword);
 | 
			
		||||
//        return CommonResult.success(productRelatedInfo);
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
@@ -0,0 +1,70 @@
 | 
			
		||||
package com.tuling.tulingmall.search.controller;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
import org.springframework.stereotype.Controller;
 | 
			
		||||
import org.springframework.web.bind.annotation.PathVariable;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMethod;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestParam;
 | 
			
		||||
import org.springframework.web.bind.annotation.ResponseBody;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
import com.tuling.tulingmall.search.service.SpringDataService;
 | 
			
		||||
import io.swagger.annotations.Api;
 | 
			
		||||
import io.swagger.annotations.ApiOperation;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 搜索商品管理Controller
 | 
			
		||||
 */
 | 
			
		||||
@Controller
 | 
			
		||||
@Api(tags = "EsProductController", description = "搜索商品管理")
 | 
			
		||||
@RequestMapping("/esProduct")
 | 
			
		||||
public class SpringDataController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private SpringDataService springDataService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "根据id创建商品")
 | 
			
		||||
    @RequestMapping(value = "/create/{id}", method = RequestMethod.GET)
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public String create(@PathVariable Long id) {
 | 
			
		||||
        EsProduct esProduct = springDataService.create(id);
 | 
			
		||||
 | 
			
		||||
        return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "根据id删除商品")
 | 
			
		||||
    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public String delete(@PathVariable Long id) {
 | 
			
		||||
        springDataService.delete(id);
 | 
			
		||||
        return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "根据id批量删除商品")
 | 
			
		||||
    @RequestMapping(value = "/delete/batch", method = RequestMethod.GET)
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public String delete(@RequestParam("ids") List<Long> ids) {
 | 
			
		||||
        springDataService.delete(ids);
 | 
			
		||||
        return "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @ApiOperation(value = "简单搜索")
 | 
			
		||||
    @RequestMapping(value = "/search/simple", method = RequestMethod.GET)
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    public String search(@RequestParam(required = false) String keyword,
 | 
			
		||||
                                                      @RequestParam(required = false, defaultValue = "0") Integer pageNum,
 | 
			
		||||
                                                      @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
 | 
			
		||||
        Page<EsProduct> esProductPage = springDataService.search(keyword, pageNum, pageSize);
 | 
			
		||||
        System.out.println("esProductPage.toString():"+esProductPage.toString()+" esProductPage.getContent():"+esProductPage.getContent().size());
 | 
			
		||||
        return esProductPage.getContent().toString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,42 @@
 | 
			
		||||
package com.tuling.tulingmall.search.controller;
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@author 图灵学院-白起老师
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.web.bind.annotation.RequestMapping;
 | 
			
		||||
import org.springframework.web.bind.annotation.ResponseBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.common.api.CommonResult;
 | 
			
		||||
import com.tuling.tulingmall.search.service.TulingMallSearchService;
 | 
			
		||||
import com.tuling.tulingmall.search.vo.ESRequestParam;
 | 
			
		||||
import com.tuling.tulingmall.search.vo.ESResponseResult;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
public class TulingMallSearchController {
 | 
			
		||||
 | 
			
		||||
     @Autowired
 | 
			
		||||
     private TulingMallSearchService  tulingMallSearchService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 自动将页面提交过来的所有请求参数封装成我们指定的对象
 | 
			
		||||
     *
 | 
			
		||||
     * @param param
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @ResponseBody
 | 
			
		||||
    @RequestMapping(value = "/searchList")
 | 
			
		||||
    public CommonResult<ESResponseResult> listPage(ESRequestParam param, HttpServletRequest request) {
 | 
			
		||||
 | 
			
		||||
        //1、根据传递来的页面的查询参数,去es中检索商品
 | 
			
		||||
        ESResponseResult searchResult = tulingMallSearchService.search(param);
 | 
			
		||||
 | 
			
		||||
        return CommonResult.success(searchResult);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,17 @@
 | 
			
		||||
package com.tuling.tulingmall.search.dao;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 搜索系统中的商品管理自定义Dao
 | 
			
		||||
 * Created on 2018/6/19.
 | 
			
		||||
 */
 | 
			
		||||
public interface EsProductDao {
 | 
			
		||||
    List<EsProduct> getAllEsProductList(@Param("id") Long id);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,189 @@
 | 
			
		||||
package com.tuling.tulingmall.search.domain;
 | 
			
		||||
 | 
			
		||||
import org.springframework.data.annotation.Id;
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.Document;
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.Field;
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.FieldType;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.math.BigDecimal;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 搜索中的商品信息
 | 
			
		||||
 * Created on 2018/6/19.
 | 
			
		||||
 */
 | 
			
		||||
@Document(indexName = "pms", type = "product",shards = 1,replicas = 0)
 | 
			
		||||
public class EsProduct implements Serializable {
 | 
			
		||||
    private static final long serialVersionUID = -1L;
 | 
			
		||||
    @Id
 | 
			
		||||
    private Long id;
 | 
			
		||||
    @Field(type = FieldType.Keyword)
 | 
			
		||||
    private String productSn;
 | 
			
		||||
    private Long brandId;
 | 
			
		||||
    @Field(type = FieldType.Keyword)
 | 
			
		||||
    private String brandName;
 | 
			
		||||
    private Long productCategoryId;
 | 
			
		||||
    @Field(type = FieldType.Keyword)
 | 
			
		||||
    private String productCategoryName;
 | 
			
		||||
    private String pic;
 | 
			
		||||
    @Field(analyzer = "ik_max_word",type = FieldType.Text)
 | 
			
		||||
    private String name;
 | 
			
		||||
    @Field(analyzer = "ik_max_word",type = FieldType.Text)
 | 
			
		||||
    private String subTitle;
 | 
			
		||||
    @Field(analyzer = "ik_max_word",type = FieldType.Text)
 | 
			
		||||
    private String keywords;
 | 
			
		||||
    private BigDecimal price;
 | 
			
		||||
    private Integer sale;
 | 
			
		||||
    private Integer newStatus;
 | 
			
		||||
    private Integer recommandStatus;
 | 
			
		||||
    private Integer stock;
 | 
			
		||||
    private Integer promotionType;
 | 
			
		||||
    private Integer sort;
 | 
			
		||||
    @Field(type =FieldType.Nested)
 | 
			
		||||
    private List<EsProductAttributeValue> attrValueList;
 | 
			
		||||
 | 
			
		||||
    public Long getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setId(Long id) {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getProductSn() {
 | 
			
		||||
        return productSn;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProductSn(String productSn) {
 | 
			
		||||
        this.productSn = productSn;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getBrandId() {
 | 
			
		||||
        return brandId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBrandId(Long brandId) {
 | 
			
		||||
        this.brandId = brandId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getBrandName() {
 | 
			
		||||
        return brandName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBrandName(String brandName) {
 | 
			
		||||
        this.brandName = brandName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getProductCategoryId() {
 | 
			
		||||
        return productCategoryId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProductCategoryId(Long productCategoryId) {
 | 
			
		||||
        this.productCategoryId = productCategoryId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getProductCategoryName() {
 | 
			
		||||
        return productCategoryName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProductCategoryName(String productCategoryName) {
 | 
			
		||||
        this.productCategoryName = productCategoryName;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPic() {
 | 
			
		||||
        return pic;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPic(String pic) {
 | 
			
		||||
        this.pic = pic;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getSubTitle() {
 | 
			
		||||
        return subTitle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSubTitle(String subTitle) {
 | 
			
		||||
        this.subTitle = subTitle;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BigDecimal getPrice() {
 | 
			
		||||
        return price;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPrice(BigDecimal price) {
 | 
			
		||||
        this.price = price;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getSale() {
 | 
			
		||||
        return sale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSale(Integer sale) {
 | 
			
		||||
        this.sale = sale;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getNewStatus() {
 | 
			
		||||
        return newStatus;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNewStatus(Integer newStatus) {
 | 
			
		||||
        this.newStatus = newStatus;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getRecommandStatus() {
 | 
			
		||||
        return recommandStatus;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRecommandStatus(Integer recommandStatus) {
 | 
			
		||||
        this.recommandStatus = recommandStatus;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getStock() {
 | 
			
		||||
        return stock;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setStock(Integer stock) {
 | 
			
		||||
        this.stock = stock;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getPromotionType() {
 | 
			
		||||
        return promotionType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPromotionType(Integer promotionType) {
 | 
			
		||||
        this.promotionType = promotionType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getSort() {
 | 
			
		||||
        return sort;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSort(Integer sort) {
 | 
			
		||||
        this.sort = sort;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<EsProductAttributeValue> getAttrValueList() {
 | 
			
		||||
        return attrValueList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAttrValueList(List<EsProductAttributeValue> attrValueList) {
 | 
			
		||||
        this.attrValueList = attrValueList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getKeywords() {
 | 
			
		||||
        return keywords;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setKeywords(String keywords) {
 | 
			
		||||
        this.keywords = keywords;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,63 @@
 | 
			
		||||
package com.tuling.tulingmall.search.domain;
 | 
			
		||||
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.Field;
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.FieldType;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 搜索中的商品属性信息
 | 
			
		||||
 * Created on 2018/6/27.
 | 
			
		||||
 */
 | 
			
		||||
public class EsProductAttributeValue implements Serializable {
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
    private Long id;
 | 
			
		||||
    private Long productAttributeId;
 | 
			
		||||
    //属性值
 | 
			
		||||
    @Field(type = FieldType.Keyword)
 | 
			
		||||
    private String value;
 | 
			
		||||
    //属性参数:0->规格;1->参数
 | 
			
		||||
    private Integer type;
 | 
			
		||||
    //属性名称
 | 
			
		||||
    @Field(type=FieldType.Keyword)
 | 
			
		||||
    private String name;
 | 
			
		||||
    public Long getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setId(Long id) {
 | 
			
		||||
        this.id = id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getProductAttributeId() {
 | 
			
		||||
        return productAttributeId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProductAttributeId(Long productAttributeId) {
 | 
			
		||||
        this.productAttributeId = productAttributeId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getValue() {
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setValue(String value) {
 | 
			
		||||
        this.value = value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getType() {
 | 
			
		||||
        return type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(Integer type) {
 | 
			
		||||
        this.type = type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,67 @@
 | 
			
		||||
package com.tuling.tulingmall.search.domain;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 搜索相关商品品牌名称,分类名称及属性
 | 
			
		||||
 * Created on 2018/6/27.
 | 
			
		||||
 */
 | 
			
		||||
public class EsProductRelatedInfo {
 | 
			
		||||
    private List<String> brandNames;
 | 
			
		||||
    private List<String> productCategoryNames;
 | 
			
		||||
    private List<ProductAttr>   productAttrs;
 | 
			
		||||
 | 
			
		||||
    public List<String> getBrandNames() {
 | 
			
		||||
        return brandNames;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBrandNames(List<String> brandNames) {
 | 
			
		||||
        this.brandNames = brandNames;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<String> getProductCategoryNames() {
 | 
			
		||||
        return productCategoryNames;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProductCategoryNames(List<String> productCategoryNames) {
 | 
			
		||||
        this.productCategoryNames = productCategoryNames;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<ProductAttr> getProductAttrs() {
 | 
			
		||||
        return productAttrs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProductAttrs(List<ProductAttr> productAttrs) {
 | 
			
		||||
        this.productAttrs = productAttrs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class ProductAttr{
 | 
			
		||||
        private Long attrId;
 | 
			
		||||
        private String attrName;
 | 
			
		||||
        private List<String> attrValues;
 | 
			
		||||
 | 
			
		||||
        public Long getAttrId() {
 | 
			
		||||
            return attrId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setAttrId(Long attrId) {
 | 
			
		||||
            this.attrId = attrId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public List<String> getAttrValues() {
 | 
			
		||||
            return attrValues;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setAttrValues(List<String> attrValues) {
 | 
			
		||||
            this.attrValues = attrValues;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getAttrName() {
 | 
			
		||||
            return attrName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setAttrName(String attrName) {
 | 
			
		||||
            this.attrName = attrName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
package com.tuling.tulingmall.search.domain;
 | 
			
		||||
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.Document;
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.Field;
 | 
			
		||||
import org.springframework.data.elasticsearch.annotations.FieldType;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 白起老师
 | 
			
		||||
 */
 | 
			
		||||
@Document(indexName = "es_test_index", type = "_doc",shards = 1,replicas = 1)
 | 
			
		||||
public class User implements Serializable {
 | 
			
		||||
    @Field(type = FieldType.Keyword)
 | 
			
		||||
    private String name;
 | 
			
		||||
 | 
			
		||||
    private int age;
 | 
			
		||||
 | 
			
		||||
    @Field(analyzer = "ik_max_word",type = FieldType.Text)
 | 
			
		||||
    private String desc;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public int getAge() {
 | 
			
		||||
        return age;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAge(int age) {
 | 
			
		||||
        this.age = age;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        return name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setName(String name) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getDesc() {
 | 
			
		||||
        return desc;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setDesc(String desc) {
 | 
			
		||||
        this.desc = desc;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public User() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public User(String name, int age, String desc) {
 | 
			
		||||
        this.name = name;
 | 
			
		||||
        this.age = age;
 | 
			
		||||
        this.desc = desc;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "User{" +
 | 
			
		||||
                "name='" + name + '\'' +
 | 
			
		||||
                ", age=" + age +
 | 
			
		||||
                ", desc='" + desc + '\'' +
 | 
			
		||||
                '}';
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,24 @@
 | 
			
		||||
package com.tuling.tulingmall.search.repository;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 商品ES操作类
 | 
			
		||||
 * Created on 2018/6/19.
 | 
			
		||||
 */
 | 
			
		||||
public interface EsProductRepository extends ElasticsearchRepository<EsProduct, Long> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 搜索查询
 | 
			
		||||
     *
 | 
			
		||||
     * @param name              商品名称
 | 
			
		||||
     * @param subTitle          商品标题
 | 
			
		||||
     * @param keywords          商品关键字
 | 
			
		||||
     * @param page              分页信息
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    Page<EsProduct> findByNameOrSubTitleOrKeywords(String name, String subTitle, String keywords,Pageable page);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,112 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.TreeMap;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 白起老师
 | 
			
		||||
 */
 | 
			
		||||
public interface EsClientSearchService {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 创建索引
 | 
			
		||||
     * @param index  索引的名称
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    boolean createIndex(String index) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取索引(一个索引相当于一个数据库,你只能判断索引是否存在)
 | 
			
		||||
     * @param index 索引名
 | 
			
		||||
     * @return
 | 
			
		||||
     * @throws IOException
 | 
			
		||||
     */
 | 
			
		||||
    boolean isExit(String index) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除索引
 | 
			
		||||
     * @param index
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    boolean delete(String index) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 添加文档
 | 
			
		||||
     * @param index 需要添加文档的索引名称
 | 
			
		||||
     * @param object 需要添加文档的内容(这里传入的是对象)
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    boolean addDocument(String index, String id, Object object) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取文档,判断是否存在 /index/doc/id
 | 
			
		||||
     * @param index
 | 
			
		||||
     * @param id
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    boolean isdocuexit(String index, String id) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取文档信息
 | 
			
		||||
     * @param index
 | 
			
		||||
     * @param id
 | 
			
		||||
     * @return 返回的是形如{"age":12,"name":"zhan"}的字符串
 | 
			
		||||
     * @throws IOException
 | 
			
		||||
     */
 | 
			
		||||
    String getDoucumment(String index, String id) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 更新文档信息
 | 
			
		||||
     * @throws IOException
 | 
			
		||||
     */
 | 
			
		||||
    boolean updateDocument(Object object, String index, String id) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除文档信息
 | 
			
		||||
     * @throws IOException
 | 
			
		||||
     */
 | 
			
		||||
    boolean deleteDocument(String index, String id) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量插入文档信息
 | 
			
		||||
     * @throws IOException
 | 
			
		||||
     */
 | 
			
		||||
    boolean addmoredocument(List<Object> list, String index, String id) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 精确查询 (例如有张三,张四,张五,要查询张三的话就只能得到一个结果即张三)
 | 
			
		||||
     * @param index
 | 
			
		||||
     * @param content 需要查询的名称
 | 
			
		||||
     * @param size 每一页需要获取多少条数据
 | 
			
		||||
     * @param from 从第几个数据开始
 | 
			
		||||
     * @return 返回SearchHit[]的数据中的每一个元素都是一个对象 形如{{name=张三, age=12},{name=张三, age=13}}
 | 
			
		||||
     */
 | 
			
		||||
    List<Map<String,Object>> termQuery(String index, TreeMap<String, Object> content, int size, int from, boolean ishigh) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 使用分词器解析进行查询 (假如要查询的是张三,则会使用ik分词器进行解析,分成张和三),代码结构与上面的基本一样
 | 
			
		||||
     * @param index
 | 
			
		||||
     * @param content key:属性 value:查询的信息
 | 
			
		||||
     * @param size
 | 
			
		||||
     * @param from
 | 
			
		||||
     * @return 返回的结果就不仅仅包含张三,也包含了姓张的用户的信息了
 | 
			
		||||
     */
 | 
			
		||||
    List<Map<String,Object>> matchQuery(String index, TreeMap<String, Object> content, int size, int from, boolean ishigh) throws IOException;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 多条件match查询 并且是查的是并集(形如where name = 'zhan' and age = 12)
 | 
			
		||||
     * @param index
 | 
			
		||||
     * @param content key:属性 value:查询的信息
 | 
			
		||||
     * @param size
 | 
			
		||||
     * @param from
 | 
			
		||||
     * @throws IOException
 | 
			
		||||
     */
 | 
			
		||||
    List<Map<String,Object>> boolmustQuery(String index, TreeMap<String, Object> content, int size, int from, boolean ishigh) throws IOException;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,53 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProductRelatedInfo;
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 商品搜索管理Service
 | 
			
		||||
 * Created on 2018/6/19.
 | 
			
		||||
 */
 | 
			
		||||
public interface EsProductService {
 | 
			
		||||
    /**
 | 
			
		||||
     * 从数据库中导入所有商品到ES
 | 
			
		||||
     */
 | 
			
		||||
    int importAll();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id删除商品
 | 
			
		||||
     */
 | 
			
		||||
    void delete(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id创建商品
 | 
			
		||||
     */
 | 
			
		||||
    EsProduct create(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量删除商品
 | 
			
		||||
     */
 | 
			
		||||
    void delete(List<Long> ids);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据关键字搜索名称或者副标题
 | 
			
		||||
     */
 | 
			
		||||
    Page<EsProduct> search(String keyword, Integer pageNum, Integer pageSize);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据关键字搜索名称或者副标题复合查询
 | 
			
		||||
     */
 | 
			
		||||
    Page<EsProduct> search(String keyword, Long brandId, Long productCategoryId, Integer pageNum, Integer pageSize,Integer sort);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据商品id推荐相关商品
 | 
			
		||||
     */
 | 
			
		||||
    Page<EsProduct> recommend(Long id, Integer pageNum, Integer pageSize);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取搜索词相关品牌、分类、属性
 | 
			
		||||
     */
 | 
			
		||||
    EsProductRelatedInfo searchRelatedInfo(String keyword);
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 商品搜索管理Service
 | 
			
		||||
 */
 | 
			
		||||
public interface SpringDataService {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id删除商品
 | 
			
		||||
     */
 | 
			
		||||
    void delete(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据id创建商品
 | 
			
		||||
     */
 | 
			
		||||
    EsProduct create(Long id);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量删除商品
 | 
			
		||||
     */
 | 
			
		||||
    void delete(List<Long> ids);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据关键字搜索名称或者副标题
 | 
			
		||||
     */
 | 
			
		||||
    Page<EsProduct> search(String keyword, Integer pageNum, Integer pageSize);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,22 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.vo.ESRequestParam;
 | 
			
		||||
import com.tuling.tulingmall.search.vo.ESResponseResult;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 白起老师
 | 
			
		||||
 */
 | 
			
		||||
public interface TulingMallSearchService {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param param 检索的所有参数
 | 
			
		||||
     * @return  返回检索的结果,里面包含页面需要的所有信息
 | 
			
		||||
     */
 | 
			
		||||
    ESResponseResult search(ESRequestParam param);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,336 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service.impl;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.TreeMap;
 | 
			
		||||
import java.util.concurrent.TimeUnit;
 | 
			
		||||
 | 
			
		||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
 | 
			
		||||
import org.elasticsearch.action.bulk.BulkRequest;
 | 
			
		||||
import org.elasticsearch.action.bulk.BulkResponse;
 | 
			
		||||
import org.elasticsearch.action.delete.DeleteRequest;
 | 
			
		||||
import org.elasticsearch.action.delete.DeleteResponse;
 | 
			
		||||
import org.elasticsearch.action.get.GetRequest;
 | 
			
		||||
import org.elasticsearch.action.get.GetResponse;
 | 
			
		||||
import org.elasticsearch.action.index.IndexRequest;
 | 
			
		||||
import org.elasticsearch.action.index.IndexResponse;
 | 
			
		||||
import org.elasticsearch.action.search.SearchRequest;
 | 
			
		||||
import org.elasticsearch.action.search.SearchResponse;
 | 
			
		||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
 | 
			
		||||
import org.elasticsearch.action.update.UpdateRequest;
 | 
			
		||||
import org.elasticsearch.action.update.UpdateResponse;
 | 
			
		||||
import org.elasticsearch.client.RequestOptions;
 | 
			
		||||
import org.elasticsearch.client.RestHighLevelClient;
 | 
			
		||||
import org.elasticsearch.client.indices.CreateIndexRequest;
 | 
			
		||||
import org.elasticsearch.client.indices.CreateIndexResponse;
 | 
			
		||||
import org.elasticsearch.client.indices.GetIndexRequest;
 | 
			
		||||
import org.elasticsearch.common.text.Text;
 | 
			
		||||
import org.elasticsearch.common.unit.TimeValue;
 | 
			
		||||
import org.elasticsearch.common.xcontent.XContentType;
 | 
			
		||||
import org.elasticsearch.index.query.BoolQueryBuilder;
 | 
			
		||||
import org.elasticsearch.index.query.MatchQueryBuilder;
 | 
			
		||||
import org.elasticsearch.index.query.QueryBuilders;
 | 
			
		||||
import org.elasticsearch.index.query.TermQueryBuilder;
 | 
			
		||||
import org.elasticsearch.search.SearchHit;
 | 
			
		||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
 | 
			
		||||
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
 | 
			
		||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
 | 
			
		||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Qualifier;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSON;
 | 
			
		||||
import com.tuling.tulingmall.search.service.EsClientSearchService;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 白起老师
 | 
			
		||||
 */
 | 
			
		||||
@Service(value="esSearchService")
 | 
			
		||||
public class EsClientClientSearchServiceImpl implements EsClientSearchService {
 | 
			
		||||
 | 
			
		||||
    @Qualifier("restHighLevelClient")
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RestHighLevelClient client;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean createIndex(String index) throws IOException {
 | 
			
		||||
        //1.创建索引请求
 | 
			
		||||
        CreateIndexRequest request = new CreateIndexRequest(index);
 | 
			
		||||
        //2.客户端执行请求IndicesClient,请求后获得相应
 | 
			
		||||
        CreateIndexResponse response = client.indices().create(request, RequestOptions.DEFAULT);
 | 
			
		||||
        return response.isAcknowledged();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isExit(String index) throws IOException {
 | 
			
		||||
        GetIndexRequest request = new GetIndexRequest(index);
 | 
			
		||||
        boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);
 | 
			
		||||
        return exists;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean delete(String index) throws IOException {
 | 
			
		||||
        DeleteIndexRequest request = new DeleteIndexRequest(index);
 | 
			
		||||
        AcknowledgedResponse delete = client.indices().delete(request, RequestOptions.DEFAULT);
 | 
			
		||||
        return delete.isAcknowledged();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean addDocument(String index, String id, Object object) throws IOException {
 | 
			
		||||
        IndexRequest request = new IndexRequest(index);
 | 
			
		||||
        //规则 一般的文档形如 put /index/_doc/1
 | 
			
		||||
        request.id(id);//如果不设置id的话会自动分配id
 | 
			
		||||
        request.timeout("1s");//设置超时时间
 | 
			
		||||
        System.out.println("JSON.toJSONString(object):"+JSON.toJSONString(object));
 | 
			
		||||
        //将我们的数据放入请求Json中
 | 
			
		||||
        request.source(JSON.toJSONString(object), XContentType.JSON);
 | 
			
		||||
        //客户端发送请求,获取相应的结果
 | 
			
		||||
        IndexResponse response = client.index(request, RequestOptions.DEFAULT);
 | 
			
		||||
        return response.getShardInfo().getSuccessful()>0?true:false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean isdocuexit(String index, String id) throws IOException {
 | 
			
		||||
        GetRequest getRequest = new GetRequest(index,id);
 | 
			
		||||
        //不获取返回的_source上下文
 | 
			
		||||
        getRequest.fetchSourceContext(new FetchSourceContext(false));
 | 
			
		||||
        getRequest.storedFields("_none_");
 | 
			
		||||
        return client.exists(getRequest, RequestOptions.DEFAULT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getDoucumment(String index, String id) throws IOException {
 | 
			
		||||
        GetRequest getRequest = new GetRequest(index, id);
 | 
			
		||||
        GetResponse response = client.get(getRequest, RequestOptions.DEFAULT);
 | 
			
		||||
        return response.getSourceAsString();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean updateDocument(Object object, String index, String id) throws IOException {
 | 
			
		||||
        UpdateRequest request = new UpdateRequest(index, id);
 | 
			
		||||
        request.timeout("1s");
 | 
			
		||||
 | 
			
		||||
        request.doc(JSON.toJSONString(object), XContentType.JSON);
 | 
			
		||||
        UpdateResponse update = client.update(request, RequestOptions.DEFAULT);
 | 
			
		||||
        return update.getShardInfo().getSuccessful()>0?true:false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean deleteDocument(String index, String id) throws IOException{
 | 
			
		||||
        DeleteRequest request = new DeleteRequest(index,id);
 | 
			
		||||
        request.timeout("1s");
 | 
			
		||||
        DeleteResponse deleteResponse = client.delete(request, RequestOptions.DEFAULT);
 | 
			
		||||
        return deleteResponse.getShardInfo().getSuccessful()>0?true:false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean addmoredocument(List<Object> list, String index, String id) throws IOException{
 | 
			
		||||
        BulkRequest bulkRequest = new BulkRequest();
 | 
			
		||||
        bulkRequest.timeout("1s");
 | 
			
		||||
        //批量处理请求
 | 
			
		||||
        for (int i=0;i<list.size();i++){
 | 
			
		||||
            bulkRequest.add(
 | 
			
		||||
                    new IndexRequest(index)
 | 
			
		||||
                            //.id(id)
 | 
			
		||||
                            .source(JSON.toJSONString(list.get(i)), XContentType.JSON));
 | 
			
		||||
        }
 | 
			
		||||
        BulkResponse responses = client.bulk(bulkRequest, RequestOptions.DEFAULT);
 | 
			
		||||
        //是否失败 false-没有失败
 | 
			
		||||
        return responses.hasFailures()?false:true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Map<String,Object>> termQuery(String index, TreeMap<String, Object> content, int size, int from, boolean ishigh) throws IOException {
 | 
			
		||||
        SearchRequest searchRequest = new SearchRequest(index);
 | 
			
		||||
        //构建查询条件
 | 
			
		||||
        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
 | 
			
		||||
        System.out.println(content.firstKey());
 | 
			
		||||
        //查询条件
 | 
			
		||||
        TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery(content.firstKey(),content.get(content.firstKey()));
 | 
			
		||||
        sourceBuilder.query(termQueryBuilder);
 | 
			
		||||
        sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //获取多少条数据
 | 
			
		||||
        sourceBuilder.size(size);
 | 
			
		||||
        //从第几行开始
 | 
			
		||||
        sourceBuilder.from(from);
 | 
			
		||||
        //是否要将查询的结果中将搜索的关键词高亮
 | 
			
		||||
        if (ishigh){
 | 
			
		||||
            HighlightBuilder highlightBuilder = new HighlightBuilder();
 | 
			
		||||
            //设置高亮的属性
 | 
			
		||||
            highlightBuilder.field(content.firstKey());
 | 
			
		||||
            //也可以自定义高亮的样式,这里我使用的是默认的方式
 | 
			
		||||
            sourceBuilder.highlighter(highlightBuilder);
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("dsl===1==="+sourceBuilder.toString());
 | 
			
		||||
        //将查询条件放入需要查询中
 | 
			
		||||
        searchRequest.source(sourceBuilder);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //获取相应的数据
 | 
			
		||||
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
 | 
			
		||||
        SearchHit[] hits = searchResponse.getHits().getHits();
 | 
			
		||||
 | 
			
		||||
        ArrayList<Map<String,Object>> result = new ArrayList<>();
 | 
			
		||||
        for (SearchHit searchHit:hits){
 | 
			
		||||
            Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
 | 
			
		||||
            //获取高亮的信息
 | 
			
		||||
            HighlightField property = highlightFields.get(content.firstKey());
 | 
			
		||||
            //查询的元素数据(没有高亮)
 | 
			
		||||
            Map<String, Object> sourceAsMap = searchHit.getSourceAsMap();
 | 
			
		||||
            if (ishigh){
 | 
			
		||||
                if (property!=null){
 | 
			
		||||
                    Text[] fragments = property.fragments();
 | 
			
		||||
                    String n_title = "";
 | 
			
		||||
                    for (Text text:fragments){
 | 
			
		||||
                        n_title += text;
 | 
			
		||||
                    }
 | 
			
		||||
                    sourceAsMap.put(content.firstKey(),n_title);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            //2.2 拿到高亮信息显示标题
 | 
			
		||||
          /*  HighlightField name = hit.getHighlightFields().get("name");
 | 
			
		||||
            //2.3 判断name中是否含有查询的关键字(因为是多字段查询,因此可能不包含指定的关键字,假设不包含则显示原始name字段的信息)
 | 
			
		||||
            String nameValue = name!=null ? name.getFragments()[0].string() : esModel.getName();
 | 
			
		||||
            esModel.setName(nameValue);*/
 | 
			
		||||
 | 
			
		||||
            result.add(sourceAsMap);
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("result==1===:"+result);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Map<String,Object>> matchQuery(String index, TreeMap<String, Object> content, int size, int from, boolean ishigh) throws IOException {
 | 
			
		||||
        SearchRequest searchRequest = new SearchRequest(index);
 | 
			
		||||
        //构建查询条件
 | 
			
		||||
        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
 | 
			
		||||
        //查询条件
 | 
			
		||||
        MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery(content.firstKey(),content.get(content.firstKey()));
 | 
			
		||||
 | 
			
		||||
        sourceBuilder.query(matchQueryBuilder);
 | 
			
		||||
        sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //获取多少条数据
 | 
			
		||||
        sourceBuilder.size(size);
 | 
			
		||||
        //从第几行开始
 | 
			
		||||
        sourceBuilder.from(from);
 | 
			
		||||
        //是否要高亮
 | 
			
		||||
        if (ishigh){
 | 
			
		||||
            HighlightBuilder highlightBuilder = new HighlightBuilder();
 | 
			
		||||
            //设置高亮的属性
 | 
			
		||||
            highlightBuilder.field(content.firstKey());
 | 
			
		||||
            //也可以自定义高亮的样式,这里我使用的是默认的方式
 | 
			
		||||
            sourceBuilder.highlighter(highlightBuilder);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        System.out.println("dsl===2==="+sourceBuilder.toString());
 | 
			
		||||
 | 
			
		||||
        //将查询条件放入需要查询中
 | 
			
		||||
        searchRequest.source(sourceBuilder);
 | 
			
		||||
        //获取相应的数据
 | 
			
		||||
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
 | 
			
		||||
        SearchHit[] hits = searchResponse.getHits().getHits();
 | 
			
		||||
 | 
			
		||||
        ArrayList<Map<String,Object>> result = new ArrayList<>();
 | 
			
		||||
        for (SearchHit searchHit:hits){
 | 
			
		||||
            Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
 | 
			
		||||
            //获取高亮的信息
 | 
			
		||||
            HighlightField property = highlightFields.get(content.firstKey());
 | 
			
		||||
            //查询的元素数据(没有高亮)
 | 
			
		||||
            Map<String, Object> sourceAsMap = searchHit.getSourceAsMap();
 | 
			
		||||
            System.out.println("sourceAsMap===2==="+sourceAsMap);
 | 
			
		||||
            if (ishigh){
 | 
			
		||||
                if (property!=null){
 | 
			
		||||
                    Text[] fragments = property.fragments();
 | 
			
		||||
                    String n_title = "";
 | 
			
		||||
                    for (Text text:fragments){
 | 
			
		||||
                        n_title += text;
 | 
			
		||||
                    }
 | 
			
		||||
                    sourceAsMap.put(content.firstKey(),n_title);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            result.add(sourceAsMap);
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("result==2===:"+result);
 | 
			
		||||
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<Map<String,Object>> boolmustQuery(String index, TreeMap<String, Object> content, int size, int from, boolean ishigh) throws IOException {
 | 
			
		||||
        SearchRequest searchRequest = new SearchRequest(index);
 | 
			
		||||
        //构建查询条件
 | 
			
		||||
        SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
 | 
			
		||||
        //查询条件
 | 
			
		||||
        BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
 | 
			
		||||
        Set keys = content.keySet();
 | 
			
		||||
        for (Object key:keys){
 | 
			
		||||
            //将要查询的条件加入
 | 
			
		||||
            boolQueryBuilder.must(QueryBuilders.termQuery((String) key,content.get(key)));
 | 
			
		||||
        }
 | 
			
		||||
        sourceBuilder.query(boolQueryBuilder);
 | 
			
		||||
        sourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
 | 
			
		||||
        //获取多少条数据
 | 
			
		||||
        sourceBuilder.size(size);
 | 
			
		||||
        //从第几行开始
 | 
			
		||||
        sourceBuilder.from(from);
 | 
			
		||||
 | 
			
		||||
        System.out.println("dsl===3==="+sourceBuilder.toString());
 | 
			
		||||
        //将查询条件放入需要查询中
 | 
			
		||||
        searchRequest.source(sourceBuilder);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //获取相应的数据
 | 
			
		||||
        SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
 | 
			
		||||
        SearchHit[] hits = searchResponse.getHits().getHits();
 | 
			
		||||
 | 
			
		||||
        ArrayList<Map<String,Object>> result = new ArrayList<>();
 | 
			
		||||
        for (SearchHit searchHit:hits){
 | 
			
		||||
            Map<String, HighlightField> highlightFields = searchHit.getHighlightFields();
 | 
			
		||||
            //获取高亮的信息
 | 
			
		||||
            HighlightField property = highlightFields.get(content.firstKey());
 | 
			
		||||
            //查询的元素数据(没有高亮)
 | 
			
		||||
            Map<String, Object> sourceAsMap = searchHit.getSourceAsMap();
 | 
			
		||||
            System.out.println("sourceAsMap===2==="+sourceAsMap);
 | 
			
		||||
            if (ishigh){
 | 
			
		||||
                if (property!=null){
 | 
			
		||||
                    Text[] fragments = property.fragments();
 | 
			
		||||
                    String n_title = "";
 | 
			
		||||
                    for (Text text:fragments){
 | 
			
		||||
                        n_title += text;
 | 
			
		||||
                    }
 | 
			
		||||
                    sourceAsMap.put(content.firstKey(),n_title);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            result.add(sourceAsMap);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        System.out.println("result==3===:"+result);
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,275 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service.impl;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.dao.EsProductDao;
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProductRelatedInfo;
 | 
			
		||||
import com.tuling.tulingmall.search.repository.EsProductRepository;
 | 
			
		||||
import com.tuling.tulingmall.search.service.EsProductService;
 | 
			
		||||
import org.elasticsearch.action.search.SearchResponse;
 | 
			
		||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
 | 
			
		||||
import org.elasticsearch.index.query.BoolQueryBuilder;
 | 
			
		||||
import org.elasticsearch.index.query.QueryBuilders;
 | 
			
		||||
import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder;
 | 
			
		||||
import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders;
 | 
			
		||||
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
 | 
			
		||||
import org.elasticsearch.search.aggregations.Aggregation;
 | 
			
		||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.nested.InternalNested;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
 | 
			
		||||
import org.elasticsearch.search.sort.SortBuilders;
 | 
			
		||||
import org.elasticsearch.search.sort.SortOrder;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
import org.springframework.data.domain.PageImpl;
 | 
			
		||||
import org.springframework.data.domain.PageRequest;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
 | 
			
		||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
 | 
			
		||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
 | 
			
		||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.util.CollectionUtils;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 商品搜索管理Service实现类
 | 
			
		||||
 * Created on 2018/6/19.
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class EsProductServiceImpl implements EsProductService {
 | 
			
		||||
    private static final Logger LOGGER = LoggerFactory.getLogger(EsProductServiceImpl.class);
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EsProductDao productDao;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EsProductRepository productRepository;
 | 
			
		||||
//    @Autowired
 | 
			
		||||
//    private ElasticsearchTemplate elasticsearchTemplate;
 | 
			
		||||
    @Override
 | 
			
		||||
    public int importAll() {
 | 
			
		||||
        List<EsProduct> esProductList = productDao.getAllEsProductList(null);
 | 
			
		||||
        Iterable<EsProduct> esProductIterable = productRepository.saveAll(esProductList);
 | 
			
		||||
        Iterator<EsProduct> iterator = esProductIterable.iterator();
 | 
			
		||||
        int result = 0;
 | 
			
		||||
        while (iterator.hasNext()) {
 | 
			
		||||
            result++;
 | 
			
		||||
            iterator.next();
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void delete(Long id) {
 | 
			
		||||
        productRepository.deleteById(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public EsProduct create(Long id) {
 | 
			
		||||
        EsProduct result = null;
 | 
			
		||||
        List<EsProduct> esProductList = productDao.getAllEsProductList(id);
 | 
			
		||||
        if (esProductList.size() > 0) {
 | 
			
		||||
            EsProduct esProduct = esProductList.get(0);
 | 
			
		||||
            result = productRepository.save(esProduct);
 | 
			
		||||
        }
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void delete(List<Long> ids) {
 | 
			
		||||
        if (!CollectionUtils.isEmpty(ids)) {
 | 
			
		||||
            List<EsProduct> esProductList = new ArrayList<>();
 | 
			
		||||
            for (Long id : ids) {
 | 
			
		||||
                EsProduct esProduct = new EsProduct();
 | 
			
		||||
                esProduct.setId(id);
 | 
			
		||||
                esProductList.add(esProduct);
 | 
			
		||||
            }
 | 
			
		||||
            productRepository.deleteAll(esProductList);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Page<EsProduct> search(String keyword, Integer pageNum, Integer pageSize) {
 | 
			
		||||
        Pageable pageable = PageRequest.of(pageNum, pageSize);
 | 
			
		||||
        return productRepository.findByNameOrSubTitleOrKeywords(keyword, keyword, keyword, pageable);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Page<EsProduct> search(String keyword, Long brandId, Long productCategoryId, Integer pageNum, Integer pageSize,Integer sort) {
 | 
			
		||||
        Pageable pageable = PageRequest.of(pageNum, pageSize);
 | 
			
		||||
        NativeSearchQueryBuilder nativeSearchQueryBuilder = new NativeSearchQueryBuilder();
 | 
			
		||||
        //分页
 | 
			
		||||
        nativeSearchQueryBuilder.withPageable(pageable);
 | 
			
		||||
        //过滤
 | 
			
		||||
        if (brandId != null || productCategoryId != null) {
 | 
			
		||||
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
 | 
			
		||||
            if (brandId != null) {
 | 
			
		||||
                boolQueryBuilder.must(QueryBuilders.termQuery("brandId", brandId));
 | 
			
		||||
            }
 | 
			
		||||
            if (productCategoryId != null) {
 | 
			
		||||
                boolQueryBuilder.must(QueryBuilders.termQuery("productCategoryId", productCategoryId));
 | 
			
		||||
            }
 | 
			
		||||
            nativeSearchQueryBuilder.withFilter(boolQueryBuilder);
 | 
			
		||||
        }
 | 
			
		||||
        //搜索
 | 
			
		||||
        if (StringUtils.isEmpty(keyword)) {
 | 
			
		||||
            nativeSearchQueryBuilder.withQuery(QueryBuilders.matchAllQuery());
 | 
			
		||||
        } else {
 | 
			
		||||
            List<FunctionScoreQueryBuilder.FilterFunctionBuilder> filterFunctionBuilders = new ArrayList<>();
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("name", keyword),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(10)));
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("subTitle", keyword),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(5)));
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("keywords", keyword),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(2)));
 | 
			
		||||
            FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()];
 | 
			
		||||
            filterFunctionBuilders.toArray(builders);
 | 
			
		||||
            FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(builders)
 | 
			
		||||
                    .scoreMode(FunctionScoreQuery.ScoreMode.SUM)
 | 
			
		||||
                    .setMinScore(2);
 | 
			
		||||
            nativeSearchQueryBuilder.withQuery(functionScoreQueryBuilder);
 | 
			
		||||
        }
 | 
			
		||||
        //排序
 | 
			
		||||
        if(sort==1){
 | 
			
		||||
            //按新品从新到旧
 | 
			
		||||
            nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("id").order(SortOrder.DESC));
 | 
			
		||||
        }else if(sort==2){
 | 
			
		||||
            //按销量从高到低
 | 
			
		||||
            nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("sale").order(SortOrder.DESC));
 | 
			
		||||
        }else if(sort==3){
 | 
			
		||||
            //按价格从低到高
 | 
			
		||||
            nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("price").order(SortOrder.ASC));
 | 
			
		||||
        }else if(sort==4){
 | 
			
		||||
            //按价格从高到低
 | 
			
		||||
            nativeSearchQueryBuilder.withSort(SortBuilders.fieldSort("price").order(SortOrder.DESC));
 | 
			
		||||
        }else{
 | 
			
		||||
            //按相关度
 | 
			
		||||
            nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC));
 | 
			
		||||
        }
 | 
			
		||||
        nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC));
 | 
			
		||||
        NativeSearchQuery searchQuery = nativeSearchQueryBuilder.build();
 | 
			
		||||
        LOGGER.info("DSL:{}", searchQuery.getQuery().toString());
 | 
			
		||||
        return productRepository.search(searchQuery);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Page<EsProduct> recommend(Long id, Integer pageNum, Integer pageSize) {
 | 
			
		||||
        Pageable pageable = PageRequest.of(pageNum, pageSize);
 | 
			
		||||
        List<EsProduct> esProductList = productDao.getAllEsProductList(id);
 | 
			
		||||
        if (esProductList.size() > 0) {
 | 
			
		||||
            EsProduct esProduct = esProductList.get(0);
 | 
			
		||||
            String keyword = esProduct.getName();
 | 
			
		||||
            Long brandId = esProduct.getBrandId();
 | 
			
		||||
            Long productCategoryId = esProduct.getProductCategoryId();
 | 
			
		||||
            //根据商品标题、品牌、分类进行搜索
 | 
			
		||||
            List<FunctionScoreQueryBuilder.FilterFunctionBuilder> filterFunctionBuilders = new ArrayList<>();
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("name", keyword),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(8)));
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("subTitle", keyword),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(2)));
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("keywords", keyword),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(2)));
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("brandId", brandId),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(10)));
 | 
			
		||||
            filterFunctionBuilders.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(QueryBuilders.matchQuery("productCategoryId", productCategoryId),
 | 
			
		||||
                    ScoreFunctionBuilders.weightFactorFunction(6)));
 | 
			
		||||
            FunctionScoreQueryBuilder.FilterFunctionBuilder[] builders = new FunctionScoreQueryBuilder.FilterFunctionBuilder[filterFunctionBuilders.size()];
 | 
			
		||||
            filterFunctionBuilders.toArray(builders);
 | 
			
		||||
            FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders.functionScoreQuery(builders)
 | 
			
		||||
                    .scoreMode(FunctionScoreQuery.ScoreMode.SUM)
 | 
			
		||||
                    .setMinScore(2);
 | 
			
		||||
            NativeSearchQueryBuilder builder = new NativeSearchQueryBuilder();
 | 
			
		||||
            builder.withQuery(functionScoreQueryBuilder);
 | 
			
		||||
            builder.withPageable(pageable);
 | 
			
		||||
            NativeSearchQuery searchQuery = builder.build();
 | 
			
		||||
            LOGGER.info("DSL:{}", searchQuery.getQuery().toString());
 | 
			
		||||
            return productRepository.search(searchQuery);
 | 
			
		||||
        }
 | 
			
		||||
        return new PageImpl<>(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public EsProductRelatedInfo searchRelatedInfo(String keyword) {
 | 
			
		||||
        NativeSearchQueryBuilder builder = new NativeSearchQueryBuilder();
 | 
			
		||||
        //搜索条件
 | 
			
		||||
        if(StringUtils.isEmpty(keyword)){
 | 
			
		||||
            builder.withQuery(QueryBuilders.matchAllQuery());
 | 
			
		||||
        }else{
 | 
			
		||||
            builder.withQuery(QueryBuilders.multiMatchQuery(keyword,"name","subTitle","keywords"));
 | 
			
		||||
        }
 | 
			
		||||
        //聚合搜索品牌名称
 | 
			
		||||
        builder.addAggregation(AggregationBuilders.terms("brandNames").field("brandName"));
 | 
			
		||||
        //集合搜索分类名称
 | 
			
		||||
        builder.addAggregation(AggregationBuilders.terms("productCategoryNames").field("productCategoryName"));
 | 
			
		||||
        //聚合搜索商品属性,去除type=1的属性
 | 
			
		||||
        AbstractAggregationBuilder aggregationBuilder = AggregationBuilders.nested("allAttrValues","attrValueList")
 | 
			
		||||
                .subAggregation(AggregationBuilders.filter("productAttrs",QueryBuilders.termQuery("attrValueList.type",1))
 | 
			
		||||
                .subAggregation(AggregationBuilders.terms("attrIds")
 | 
			
		||||
                        .field("attrValueList.productAttributeId")
 | 
			
		||||
                        .subAggregation(AggregationBuilders.terms("attrValues")
 | 
			
		||||
                                .field("attrValueList.value"))
 | 
			
		||||
                        .subAggregation(AggregationBuilders.terms("attrNames")
 | 
			
		||||
                                .field("attrValueList.name"))));
 | 
			
		||||
        builder.addAggregation(aggregationBuilder);
 | 
			
		||||
        NativeSearchQuery searchQuery = builder.build();
 | 
			
		||||
//        return elasticsearchTemplate.search(searchQuery, response -> {
 | 
			
		||||
//            LOGGER.info("DSL:{}",searchQuery.getQuery().toString());
 | 
			
		||||
//            return convertProductRelatedInfo(response);
 | 
			
		||||
//        });
 | 
			
		||||
        return null;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 将返回结果转换为对象
 | 
			
		||||
     */
 | 
			
		||||
    private EsProductRelatedInfo convertProductRelatedInfo(SearchResponse response) {
 | 
			
		||||
        EsProductRelatedInfo productRelatedInfo = new EsProductRelatedInfo();
 | 
			
		||||
        Map<String, Aggregation> aggregationMap = response.getAggregations().getAsMap();
 | 
			
		||||
        //设置品牌
 | 
			
		||||
        Aggregation brandNames = aggregationMap.get("brandNames");
 | 
			
		||||
        List<String> brandNameList = new ArrayList<>();
 | 
			
		||||
        for(int i = 0; i<((Terms) brandNames).getBuckets().size(); i++){
 | 
			
		||||
            brandNameList.add(((Terms) brandNames).getBuckets().get(i).getKeyAsString());
 | 
			
		||||
        }
 | 
			
		||||
        productRelatedInfo.setBrandNames(brandNameList);
 | 
			
		||||
        //设置分类
 | 
			
		||||
        Aggregation productCategoryNames = aggregationMap.get("productCategoryNames");
 | 
			
		||||
        List<String> productCategoryNameList = new ArrayList<>();
 | 
			
		||||
        for(int i=0;i<((Terms) productCategoryNames).getBuckets().size();i++){
 | 
			
		||||
            productCategoryNameList.add(((Terms) productCategoryNames).getBuckets().get(i).getKeyAsString());
 | 
			
		||||
        }
 | 
			
		||||
        productRelatedInfo.setProductCategoryNames(productCategoryNameList);
 | 
			
		||||
        //设置参数
 | 
			
		||||
        Aggregation productAttrs = aggregationMap.get("allAttrValues");
 | 
			
		||||
        List<LongTerms.Bucket> attrIds = ((LongTerms) ((InternalFilter) ((InternalNested) productAttrs).getProperty("productAttrs")).getProperty("attrIds")).getBuckets();
 | 
			
		||||
        List<EsProductRelatedInfo.ProductAttr> attrList = new ArrayList<>();
 | 
			
		||||
        for (Terms.Bucket attrId : attrIds) {
 | 
			
		||||
            EsProductRelatedInfo.ProductAttr attr = new EsProductRelatedInfo.ProductAttr();
 | 
			
		||||
            attr.setAttrId((Long) attrId.getKey());
 | 
			
		||||
            List<String> attrValueList = new ArrayList<>();
 | 
			
		||||
            List<StringTerms.Bucket> attrValues = ((StringTerms) attrId.getAggregations().get("attrValues")).getBuckets();
 | 
			
		||||
            List<StringTerms.Bucket> attrNames = ((StringTerms) attrId.getAggregations().get("attrNames")).getBuckets();
 | 
			
		||||
            for (Terms.Bucket attrValue : attrValues) {
 | 
			
		||||
                attrValueList.add(attrValue.getKeyAsString());
 | 
			
		||||
            }
 | 
			
		||||
            attr.setAttrValues(attrValueList);
 | 
			
		||||
            if(!CollectionUtils.isEmpty(attrNames)){
 | 
			
		||||
                String attrName = attrNames.get(0).getKeyAsString();
 | 
			
		||||
                attr.setAttrName(attrName);
 | 
			
		||||
            }
 | 
			
		||||
            attrList.add(attr);
 | 
			
		||||
        }
 | 
			
		||||
        productRelatedInfo.setProductAttrs(attrList);
 | 
			
		||||
        return productRelatedInfo;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,81 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service.impl;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.elasticsearch.client.RestHighLevelClient;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Qualifier;
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
import org.springframework.data.domain.PageRequest;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
import com.tuling.tulingmall.search.repository.EsProductRepository;
 | 
			
		||||
import com.tuling.tulingmall.search.service.SpringDataService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 商品搜索管理Service实现类
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class SpringDataServiceImpl implements SpringDataService {
 | 
			
		||||
 | 
			
		||||
    private static final Logger LOGGER = LoggerFactory.getLogger(SpringDataServiceImpl.class);
 | 
			
		||||
 | 
			
		||||
    @Qualifier("restHighLevelClient")
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RestHighLevelClient client;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EsProductRepository productRepository;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public EsProduct create(Long id) {
 | 
			
		||||
        EsProduct esProduct = new EsProduct();
 | 
			
		||||
        esProduct.setId(id);
 | 
			
		||||
        esProduct.setName("测试产品:"+id);
 | 
			
		||||
        esProduct.setBrandId(1L);
 | 
			
		||||
 | 
			
		||||
        productRepository.save(esProduct);
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void delete(Long id) {
 | 
			
		||||
        productRepository.deleteById(id);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void delete(List<Long> ids) {
 | 
			
		||||
        if (ids!=null && ids.size() > 0) {
 | 
			
		||||
            List<EsProduct> esProductList = new ArrayList<>();
 | 
			
		||||
            for (Long id : ids) {
 | 
			
		||||
                EsProduct esProduct = new EsProduct();
 | 
			
		||||
                esProduct.setId(id);
 | 
			
		||||
                esProductList.add(esProduct);
 | 
			
		||||
            }
 | 
			
		||||
            productRepository.deleteAll(esProductList);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Page<EsProduct> search(String keyword, Integer pageNum, Integer pageSize) {
 | 
			
		||||
        Pageable pageable = PageRequest.of(pageNum, pageSize);
 | 
			
		||||
        return productRepository.findByNameOrSubTitleOrKeywords(keyword, keyword, keyword, pageable);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,377 @@
 | 
			
		||||
package com.tuling.tulingmall.search.service.impl;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
import org.apache.lucene.search.join.ScoreMode;
 | 
			
		||||
import org.elasticsearch.action.search.SearchRequest;
 | 
			
		||||
import org.elasticsearch.action.search.SearchResponse;
 | 
			
		||||
import org.elasticsearch.client.RequestOptions;
 | 
			
		||||
import org.elasticsearch.client.RestHighLevelClient;
 | 
			
		||||
import org.elasticsearch.index.query.BoolQueryBuilder;
 | 
			
		||||
import org.elasticsearch.index.query.NestedQueryBuilder;
 | 
			
		||||
import org.elasticsearch.index.query.QueryBuilders;
 | 
			
		||||
import org.elasticsearch.index.query.RangeQueryBuilder;
 | 
			
		||||
import org.elasticsearch.search.SearchHit;
 | 
			
		||||
import org.elasticsearch.search.SearchHits;
 | 
			
		||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.ParsedLongTerms;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.ParsedStringTerms;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
 | 
			
		||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
 | 
			
		||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
 | 
			
		||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
 | 
			
		||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
 | 
			
		||||
import org.elasticsearch.search.sort.SortOrder;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Qualifier;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
 | 
			
		||||
import com.alibaba.fastjson.JSON;
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
import com.tuling.tulingmall.search.service.TulingMallSearchService;
 | 
			
		||||
import com.tuling.tulingmall.search.utils.SearchConstant;
 | 
			
		||||
import com.tuling.tulingmall.search.vo.ESRequestParam;
 | 
			
		||||
import com.tuling.tulingmall.search.vo.ESResponseResult;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 白起老师
 | 
			
		||||
 */
 | 
			
		||||
@Service(value="tulingMallSearchService")
 | 
			
		||||
public class TulingMallSearchServiceImpl implements TulingMallSearchService {
 | 
			
		||||
 | 
			
		||||
    @Qualifier("restHighLevelClient")
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private RestHighLevelClient client;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**************************图灵商城搜索*****************************/
 | 
			
		||||
    @Override
 | 
			
		||||
    public ESResponseResult search(ESRequestParam param) {
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            //1、构建检索对象-封装请求相关参数信息
 | 
			
		||||
            SearchRequest searchRequest = startBuildRequestParam(param);
 | 
			
		||||
 | 
			
		||||
            //2、进行检索操作
 | 
			
		||||
            SearchResponse response = client.search(searchRequest, RequestOptions.DEFAULT);
 | 
			
		||||
            System.out.println("response:"+response);
 | 
			
		||||
            //3、分析响应数据,封装成指定的格式
 | 
			
		||||
            ESResponseResult responseResult = startBuildResponseResult(response, param);
 | 
			
		||||
            return responseResult;
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 封装请求参数信息
 | 
			
		||||
     * 关键字查询、根据属性、分类、品牌、价格区间、是否有库存等进行过滤、分页、高亮、以及聚合统计品牌分类属性
 | 
			
		||||
     *
 | 
			
		||||
     */
 | 
			
		||||
    private SearchRequest startBuildRequestParam(ESRequestParam param) {
 | 
			
		||||
 | 
			
		||||
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * 关键字查询、根据属性、分类、品牌、价格区间、是否有库存等进行过滤、分页、高亮、以及聚合统计品牌分类属性
 | 
			
		||||
         */
 | 
			
		||||
        BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
 | 
			
		||||
 | 
			
		||||
        //1、查询关键字
 | 
			
		||||
        if (!StringUtils.isEmpty(param.getKeyword())) {
 | 
			
		||||
            //单字段查询
 | 
			
		||||
            //boolQueryBuilder.must(QueryBuilders.matchQuery("name", param.getKeyword()));
 | 
			
		||||
            //多字段查询
 | 
			
		||||
            boolQueryBuilder.must(QueryBuilders.multiMatchQuery(param.getKeyword(),"name","keywords","subTitle"));
 | 
			
		||||
        }
 | 
			
		||||
        //2、根据类目ID进行过滤
 | 
			
		||||
        if (null != param.getCategoryId()) {
 | 
			
		||||
            boolQueryBuilder.filter(QueryBuilders.termQuery("categoryId", param.getCategoryId()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //3、根据品牌ID进行过滤
 | 
			
		||||
        if (null != param.getBrandId() && param.getBrandId().size() > 0) {
 | 
			
		||||
            boolQueryBuilder.filter(QueryBuilders.termsQuery("brandId", param.getBrandId()));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //4、根据属性进行相关过滤
 | 
			
		||||
        if (param.getAttrs() != null && param.getAttrs().size() > 0) {
 | 
			
		||||
 | 
			
		||||
            param.getAttrs().forEach(item -> {
 | 
			
		||||
                //attrs=1_白色&2_4核
 | 
			
		||||
                BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
 | 
			
		||||
 | 
			
		||||
                //attrs=1_64G
 | 
			
		||||
                String[] s = item.split("_");
 | 
			
		||||
                String attrId = s[0];
 | 
			
		||||
                String[] attrValues = s[1].split(":");//这个属性检索用的值
 | 
			
		||||
                boolQuery.must(QueryBuilders.termQuery("attrs.attrId", attrId));
 | 
			
		||||
                boolQuery.must(QueryBuilders.termsQuery("attrs.attrValue", attrValues));
 | 
			
		||||
 | 
			
		||||
                NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("attrs", boolQuery, ScoreMode.None);
 | 
			
		||||
                boolQueryBuilder.filter(nestedQueryBuilder);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //5、是否有库存
 | 
			
		||||
        if (null != param.getHasStock()) {
 | 
			
		||||
            boolQueryBuilder.filter(QueryBuilders.termQuery("hasStock", param.getHasStock() == 1));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //6、根据价格过滤
 | 
			
		||||
        if (!StringUtils.isEmpty(param.getPrice())) {
 | 
			
		||||
            //价格的输入形式为:10_100(起始价格和最终价格)或_100(不指定起始价格)或10_(不限制最终价格)
 | 
			
		||||
            RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery("price");
 | 
			
		||||
            String[] price = param.getPrice().split("_");
 | 
			
		||||
            if (price.length == 2) {
 | 
			
		||||
                    //price: _5000
 | 
			
		||||
                    if (param.getPrice().startsWith("_")) {
 | 
			
		||||
                        rangeQueryBuilder.lte(price[1]);
 | 
			
		||||
                    }
 | 
			
		||||
                else{
 | 
			
		||||
                        //price: 1_5000
 | 
			
		||||
                        rangeQueryBuilder.gte(price[0]).lte(price[1]);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            } else if (price.length == 1) {
 | 
			
		||||
                 //price: 1_
 | 
			
		||||
                if (param.getPrice().endsWith("_")) {
 | 
			
		||||
                    rangeQueryBuilder.gte(price[0]);
 | 
			
		||||
                }
 | 
			
		||||
                //price: _5000
 | 
			
		||||
                if (param.getPrice().startsWith("_")) {
 | 
			
		||||
                    rangeQueryBuilder.lte(price[0]);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            boolQueryBuilder.filter(rangeQueryBuilder);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //封装所有查询条件
 | 
			
		||||
        searchSourceBuilder.query(boolQueryBuilder);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * 实现排序、高亮、分页操作
 | 
			
		||||
         */
 | 
			
		||||
 | 
			
		||||
        //排序
 | 
			
		||||
        //页面传入的参数值形式 sort=price_asc/desc
 | 
			
		||||
        if (!StringUtils.isEmpty(param.getSort())) {
 | 
			
		||||
            String sort = param.getSort();
 | 
			
		||||
            String[] sortFileds = sort.split("_");
 | 
			
		||||
 | 
			
		||||
            if(!StringUtils.isEmpty(sortFileds[0])){
 | 
			
		||||
                SortOrder sortOrder = "asc".equalsIgnoreCase(sortFileds[1]) ? SortOrder.ASC : SortOrder.DESC;
 | 
			
		||||
                searchSourceBuilder.sort(sortFileds[0], sortOrder);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //分页查询
 | 
			
		||||
        searchSourceBuilder.from((param.getPageNum() - 1) * SearchConstant.PAGE_SIZE);
 | 
			
		||||
        searchSourceBuilder.size(SearchConstant.PAGE_SIZE);
 | 
			
		||||
 | 
			
		||||
        //高亮显示
 | 
			
		||||
        if (!StringUtils.isEmpty(param.getKeyword())) {
 | 
			
		||||
 | 
			
		||||
            HighlightBuilder highlightBuilder = new HighlightBuilder();
 | 
			
		||||
            highlightBuilder.field("name");
 | 
			
		||||
            highlightBuilder.preTags("<b style='color:red'>");
 | 
			
		||||
            highlightBuilder.postTags("</b>");
 | 
			
		||||
 | 
			
		||||
            searchSourceBuilder.highlighter(highlightBuilder);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * 对品牌、分类信息、属性信息进行聚合分析
 | 
			
		||||
         */
 | 
			
		||||
        //1. 按照品牌进行聚合
 | 
			
		||||
        TermsAggregationBuilder brand_agg = AggregationBuilders.terms("brand_agg");
 | 
			
		||||
        brand_agg.field("brandId").size(50);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //1.1 品牌的子聚合-品牌名聚合
 | 
			
		||||
        brand_agg.subAggregation(AggregationBuilders.terms("brand_name_agg").field("brandName").size(1));
 | 
			
		||||
        //1.2 品牌的子聚合-品牌图片聚合
 | 
			
		||||
        brand_agg.subAggregation(AggregationBuilders.terms("brand_img_agg").field("brandImg").size(1));
 | 
			
		||||
 | 
			
		||||
        searchSourceBuilder.aggregation(brand_agg);
 | 
			
		||||
 | 
			
		||||
        //2. 按照分类信息进行聚合
 | 
			
		||||
        TermsAggregationBuilder category_agg = AggregationBuilders.terms("category_agg");
 | 
			
		||||
        category_agg.field("categoryId").size(50);
 | 
			
		||||
 | 
			
		||||
        category_agg.subAggregation(AggregationBuilders.terms("category_name_agg").field("categoryName").size(1));
 | 
			
		||||
 | 
			
		||||
        searchSourceBuilder.aggregation(category_agg);
 | 
			
		||||
 | 
			
		||||
        //2. 按照属性信息进行聚合
 | 
			
		||||
        NestedAggregationBuilder attr_agg = AggregationBuilders.nested("attr_agg", "attrs");
 | 
			
		||||
        //2.1 按照属性ID进行聚合
 | 
			
		||||
        TermsAggregationBuilder attr_id_agg = AggregationBuilders.terms("attr_id_agg").field("attrs.attrId");
 | 
			
		||||
        attr_agg.subAggregation(attr_id_agg);
 | 
			
		||||
        //2.1.1 在每个属性ID下,按照属性名进行聚合
 | 
			
		||||
        attr_id_agg.subAggregation(AggregationBuilders.terms("attr_name_agg").field("attrs.attrName").size(1));
 | 
			
		||||
        //2.1.1 在每个属性ID下,按照属性值进行聚合
 | 
			
		||||
        attr_id_agg.subAggregation(AggregationBuilders.terms("attr_value_agg").field("attrs.attrValue").size(50));
 | 
			
		||||
        searchSourceBuilder.aggregation(attr_agg);
 | 
			
		||||
 | 
			
		||||
        System.out.println("构建的DSL语句 {}:"+ searchSourceBuilder.toString());
 | 
			
		||||
 | 
			
		||||
        SearchRequest searchRequest = new SearchRequest(new String[]{SearchConstant.INDEX_NAME}, searchSourceBuilder);
 | 
			
		||||
 | 
			
		||||
        return searchRequest;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 封装查询到的结果信息
 | 
			
		||||
     * 关键字查询、根据属性、分类、品牌、价格区间、是否有库存等进行过滤、分页、高亮、以及聚合统计品牌分类属性
 | 
			
		||||
     */
 | 
			
		||||
    private ESResponseResult startBuildResponseResult(SearchResponse response, ESRequestParam param) {
 | 
			
		||||
 | 
			
		||||
       ESResponseResult result = new ESResponseResult();
 | 
			
		||||
 | 
			
		||||
        //1、获取查询到的商品信息
 | 
			
		||||
        SearchHits hits = response.getHits();
 | 
			
		||||
 | 
			
		||||
        List<EsProduct> esModels = new ArrayList<>();
 | 
			
		||||
        //2、遍历所有商品信息
 | 
			
		||||
        if (hits.getHits() != null && hits.getHits().length > 0) {
 | 
			
		||||
            for (SearchHit hit : hits.getHits()) {
 | 
			
		||||
                String sourceAsString = hit.getSourceAsString();
 | 
			
		||||
                EsProduct esModel = JSON.parseObject(sourceAsString, EsProduct.class);
 | 
			
		||||
 | 
			
		||||
                    //2.1 判断是否按关键字检索,若是就显示高亮,否则不显示
 | 
			
		||||
                if (!StringUtils.isEmpty(param.getKeyword())) {
 | 
			
		||||
                    //2.2 拿到高亮信息显示标题
 | 
			
		||||
                    HighlightField name = hit.getHighlightFields().get("name");
 | 
			
		||||
                    //2.3 判断name中是否含有查询的关键字(因为是多字段查询,因此可能不包含指定的关键字,假设不包含则显示原始name字段的信息)
 | 
			
		||||
                    String nameValue = name!=null ? name.getFragments()[0].string() : esModel.getName();
 | 
			
		||||
                    esModel.setName(nameValue);
 | 
			
		||||
                }
 | 
			
		||||
                esModels.add(esModel);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        result.setProducts(esModels);
 | 
			
		||||
 | 
			
		||||
        //3、当前商品涉及到的所有品牌信息,小米手机和小米电脑都属于小米品牌,过滤重复品牌信息
 | 
			
		||||
        List<ESResponseResult.BrandVo> brandVos = new ArrayList<>();
 | 
			
		||||
        //获取到品牌的聚合
 | 
			
		||||
        ParsedLongTerms brandAgg = response.getAggregations().get("brand_agg");
 | 
			
		||||
        for (Terms.Bucket bucket : brandAgg.getBuckets()) {
 | 
			
		||||
            ESResponseResult.BrandVo brandVo = new ESResponseResult.BrandVo();
 | 
			
		||||
 | 
			
		||||
            //获取品牌的id
 | 
			
		||||
            long brandId = bucket.getKeyAsNumber().longValue();
 | 
			
		||||
            brandVo.setBrandId(brandId);
 | 
			
		||||
 | 
			
		||||
            //获取品牌的名字
 | 
			
		||||
            ParsedStringTerms brandNameAgg = bucket.getAggregations().get("brand_name_agg");
 | 
			
		||||
            String brandName = brandNameAgg.getBuckets().get(0).getKeyAsString();
 | 
			
		||||
            brandVo.setBrandName(brandName);
 | 
			
		||||
 | 
			
		||||
            //获取品牌的LOGO
 | 
			
		||||
            ParsedStringTerms brandImgAgg = bucket.getAggregations().get("brand_img_agg");
 | 
			
		||||
            String brandImg = brandImgAgg.getBuckets().get(0).getKeyAsString();
 | 
			
		||||
            brandVo.setBrandImg(brandImg);
 | 
			
		||||
            System.out.println("brandId:"+brandId+"brandName:"+brandName+"brandImg");
 | 
			
		||||
            brandVos.add(brandVo);
 | 
			
		||||
        }
 | 
			
		||||
        System.out.println("brandVos.size:"+brandVos.size());
 | 
			
		||||
        result.setBrands(brandVos);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //4、当前商品相关的所有类目信息
 | 
			
		||||
        //获取到分类的聚合
 | 
			
		||||
        List<ESResponseResult.categoryVo> categoryVos = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        ParsedLongTerms categoryAgg = response.getAggregations().get("category_agg");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        for (Terms.Bucket bucket : categoryAgg.getBuckets()) {
 | 
			
		||||
            ESResponseResult.categoryVo categoryVo = new ESResponseResult.categoryVo();
 | 
			
		||||
            //获取分类id
 | 
			
		||||
            String keyAsString = bucket.getKeyAsString();
 | 
			
		||||
            categoryVo.setCategoryId(Long.parseLong(keyAsString));
 | 
			
		||||
 | 
			
		||||
            //获取分类名
 | 
			
		||||
            ParsedStringTerms categoryNameAgg = bucket.getAggregations().get("category_name_agg");
 | 
			
		||||
            String categoryName = categoryNameAgg.getBuckets().get(0).getKeyAsString();
 | 
			
		||||
            categoryVo.setCategoryName(categoryName);
 | 
			
		||||
            categoryVos.add(categoryVo);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        result.setCategorys(categoryVos);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //5、获取商品相关的所有属性信息
 | 
			
		||||
        List<ESResponseResult.AttrVo> attrVos = new ArrayList<>();
 | 
			
		||||
        //获取属性信息的聚合
 | 
			
		||||
        ParsedNested attrsAgg = response.getAggregations().get("attr_agg");
 | 
			
		||||
        ParsedLongTerms attrIdAgg = attrsAgg.getAggregations().get("attr_id_agg");
 | 
			
		||||
        for (Terms.Bucket bucket : attrIdAgg.getBuckets()) {
 | 
			
		||||
            ESResponseResult.AttrVo attrVo = new ESResponseResult.AttrVo();
 | 
			
		||||
            //获取属性ID值
 | 
			
		||||
            long attrId = bucket.getKeyAsNumber().longValue();
 | 
			
		||||
            attrVo.setAttrId(attrId);
 | 
			
		||||
 | 
			
		||||
            //获取属性的名字
 | 
			
		||||
            ParsedStringTerms attrNameAgg = bucket.getAggregations().get("attr_name_agg");
 | 
			
		||||
            String attrName = attrNameAgg.getBuckets().get(0).getKeyAsString();
 | 
			
		||||
            attrVo.setAttrName(attrName);
 | 
			
		||||
 | 
			
		||||
            //获取属性的值
 | 
			
		||||
            ParsedStringTerms attrValueAgg = bucket.getAggregations().get("attr_value_agg");
 | 
			
		||||
            System.out.println("===1==="+attrValueAgg.getBuckets());
 | 
			
		||||
 | 
			
		||||
            for (Terms.Bucket b : attrValueAgg.getBuckets()) {
 | 
			
		||||
                 String bb = b.getKeyAsString();
 | 
			
		||||
                System.out.println("bb:"+bb);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            List<String> attrValues = attrValueAgg.getBuckets().stream().map(item -> item.getKeyAsString()).collect(Collectors.toList());
 | 
			
		||||
            attrVo.setAttrValue(attrValues);
 | 
			
		||||
            System.out.println("===2==="+attrValues);
 | 
			
		||||
            attrVos.add(attrVo);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        result.setAttrs(attrVos);
 | 
			
		||||
 | 
			
		||||
        //6、进行分页操作
 | 
			
		||||
        result.setPageNum(param.getPageNum());
 | 
			
		||||
        //获取总记录数
 | 
			
		||||
        long total = hits.getTotalHits().value;
 | 
			
		||||
        result.setTotal(total);
 | 
			
		||||
 | 
			
		||||
        //计算总页码
 | 
			
		||||
        int totalPages = (int) total % SearchConstant.PAGE_SIZE == 0 ?
 | 
			
		||||
                (int) total / SearchConstant.PAGE_SIZE : ((int) total / SearchConstant.PAGE_SIZE + 1);
 | 
			
		||||
        result.setTotalPages(totalPages);
 | 
			
		||||
 | 
			
		||||
        List<Integer> pageNavs = new ArrayList<>();
 | 
			
		||||
        for (int i = 1; i <= totalPages; i++) {
 | 
			
		||||
            pageNavs.add(i);
 | 
			
		||||
        }
 | 
			
		||||
        result.setPageNavs(pageNavs);
 | 
			
		||||
 | 
			
		||||
        return result;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,14 @@
 | 
			
		||||
package com.tuling.tulingmall.search.utils;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 白起老师
 | 
			
		||||
 */
 | 
			
		||||
public class SearchConstant {
 | 
			
		||||
 | 
			
		||||
    //声明索引库名字
 | 
			
		||||
    public static final String INDEX_NAME = "product_db";
 | 
			
		||||
 | 
			
		||||
    //指定每页显示的商品的数量
 | 
			
		||||
    public static final Integer PAGE_SIZE = 10;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,148 @@
 | 
			
		||||
package com.tuling.tulingmall.search.vo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author: baiqi
 | 
			
		||||
 */
 | 
			
		||||
public class ESRequestParam {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 页面传递过来的全文匹配关键字
 | 
			
		||||
     */
 | 
			
		||||
    private String keyword;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 品牌id,可以多选
 | 
			
		||||
     */
 | 
			
		||||
    private List<Long> brandId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 分类id
 | 
			
		||||
     */
 | 
			
		||||
    private Long categoryId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 排序条件:sort=price/salecount/hotscore_desc/asc
 | 
			
		||||
     */
 | 
			
		||||
    private String sort;
 | 
			
		||||
 | 
			
		||||
    private Long salecount;//销量
 | 
			
		||||
 | 
			
		||||
    private Date putawayDate;//上架时间
 | 
			
		||||
    /**
 | 
			
		||||
     * 是否显示有货  1代表有货
 | 
			
		||||
     */
 | 
			
		||||
    private Integer hasStock;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 价格区间查询
 | 
			
		||||
     */
 | 
			
		||||
    private String price;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 按照属性进行筛选
 | 
			
		||||
     */
 | 
			
		||||
    private List<String> attrs;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 页码
 | 
			
		||||
     */
 | 
			
		||||
    private Integer pageNum = 1;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 原生的所有查询条件
 | 
			
		||||
     */
 | 
			
		||||
    private String queryString;
 | 
			
		||||
 | 
			
		||||
    public String getKeyword() {
 | 
			
		||||
        return keyword;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setKeyword(String keyword) {
 | 
			
		||||
        this.keyword = keyword;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<Long> getBrandId() {
 | 
			
		||||
        return brandId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBrandId(List<Long> brandId) {
 | 
			
		||||
        this.brandId = brandId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getSort() {
 | 
			
		||||
        return sort;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSort(String sort) {
 | 
			
		||||
        this.sort = sort;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getHasStock() {
 | 
			
		||||
        return hasStock;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHasStock(Integer hasStock) {
 | 
			
		||||
        this.hasStock = hasStock;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getPrice() {
 | 
			
		||||
        return price;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPrice(String price) {
 | 
			
		||||
        this.price = price;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<String> getAttrs() {
 | 
			
		||||
        return attrs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAttrs(List<String> attrs) {
 | 
			
		||||
        this.attrs = attrs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getPageNum() {
 | 
			
		||||
        return pageNum;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPageNum(Integer pageNum) {
 | 
			
		||||
        this.pageNum = pageNum;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public String getQueryString() {
 | 
			
		||||
        return queryString;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setQueryString(String queryString) {
 | 
			
		||||
        this.queryString = queryString;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getCategoryId() {
 | 
			
		||||
        return categoryId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCategoryId(Long categoryId) {
 | 
			
		||||
        this.categoryId = categoryId;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getSalecount() {
 | 
			
		||||
        return salecount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSalecount(Long salecount) {
 | 
			
		||||
        this.salecount = salecount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Date getPutawayDate() {
 | 
			
		||||
        return putawayDate;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPutawayDate(Date putawayDate) {
 | 
			
		||||
        this.putawayDate = putawayDate;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,260 @@
 | 
			
		||||
package com.tuling.tulingmall.search.vo;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author: baiqi
 | 
			
		||||
 */
 | 
			
		||||
public class ESResponseResult {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询到的所有商品信息
 | 
			
		||||
     */
 | 
			
		||||
    private List<EsProduct> products;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前页码
 | 
			
		||||
     */
 | 
			
		||||
    private Integer pageNum;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 总记录数
 | 
			
		||||
     */
 | 
			
		||||
    private Long total;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 总页码
 | 
			
		||||
     */
 | 
			
		||||
    private Integer totalPages;
 | 
			
		||||
 | 
			
		||||
    private List<Integer> pageNavs;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前查询到的结果,所有涉及到的品牌
 | 
			
		||||
     */
 | 
			
		||||
    private List<BrandVo> brands;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前查询到的结果,所有涉及到的所有属性
 | 
			
		||||
     */
 | 
			
		||||
    private List<AttrVo> attrs;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 当前查询到的结果,所有涉及到的所有分类
 | 
			
		||||
     */
 | 
			
		||||
    private List<categoryVo> categorys;
 | 
			
		||||
 | 
			
		||||
    public List<EsProduct> getProducts() {
 | 
			
		||||
        return products;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProducts(List<EsProduct> products) {
 | 
			
		||||
        this.products = products;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<categoryVo> getCategorys() {
 | 
			
		||||
        return categorys;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCategorys(List<categoryVo> categorys) {
 | 
			
		||||
        this.categorys = categorys;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getPageNum() {
 | 
			
		||||
        return pageNum;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPageNum(Integer pageNum) {
 | 
			
		||||
        this.pageNum = pageNum;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Long getTotal() {
 | 
			
		||||
        return total;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTotal(Long total) {
 | 
			
		||||
        this.total = total;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Integer getTotalPages() {
 | 
			
		||||
        return totalPages;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTotalPages(Integer totalPages) {
 | 
			
		||||
        this.totalPages = totalPages;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<Integer> getPageNavs() {
 | 
			
		||||
        return pageNavs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPageNavs(List<Integer> pageNavs) {
 | 
			
		||||
        this.pageNavs = pageNavs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<BrandVo> getBrands() {
 | 
			
		||||
        return brands;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBrands(List<BrandVo> brands) {
 | 
			
		||||
        this.brands = brands;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<AttrVo> getAttrs() {
 | 
			
		||||
        return attrs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAttrs(List<AttrVo> attrs) {
 | 
			
		||||
        this.attrs = attrs;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //===========================以上是返回给页面的所有信息============================//
 | 
			
		||||
 | 
			
		||||
    public static class NavVo {
 | 
			
		||||
        private String navName;
 | 
			
		||||
        private String navValue;
 | 
			
		||||
        private String link;
 | 
			
		||||
 | 
			
		||||
        public String getNavName() {
 | 
			
		||||
            return navName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setNavName(String navName) {
 | 
			
		||||
            this.navName = navName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getNavValue() {
 | 
			
		||||
            return navValue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setNavValue(String navValue) {
 | 
			
		||||
            this.navValue = navValue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getLink() {
 | 
			
		||||
            return link;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setLink(String link) {
 | 
			
		||||
            this.link = link;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static class BrandVo {
 | 
			
		||||
 | 
			
		||||
        private Long brandId;
 | 
			
		||||
 | 
			
		||||
        private String brandName;
 | 
			
		||||
 | 
			
		||||
        private String brandImg;
 | 
			
		||||
 | 
			
		||||
        public Long getBrandId() {
 | 
			
		||||
            return brandId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setBrandId(Long brandId) {
 | 
			
		||||
            this.brandId = brandId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getBrandName() {
 | 
			
		||||
            return brandName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setBrandName(String brandName) {
 | 
			
		||||
            this.brandName = brandName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getBrandImg() {
 | 
			
		||||
            return brandImg;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setBrandImg(String brandImg) {
 | 
			
		||||
            this.brandImg = brandImg;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public boolean equals(Object o) {
 | 
			
		||||
            if (this == o) return true;
 | 
			
		||||
            if (o == null || getClass() != o.getClass()) return false;
 | 
			
		||||
            BrandVo brandVo = (BrandVo) o;
 | 
			
		||||
            return Objects.equals(brandId, brandVo.brandId) &&
 | 
			
		||||
                    Objects.equals(brandName, brandVo.brandName) &&
 | 
			
		||||
                    Objects.equals(brandImg, brandVo.brandImg);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public int hashCode() {
 | 
			
		||||
            return Objects.hash(brandId, brandName, brandImg);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static class AttrVo {
 | 
			
		||||
 | 
			
		||||
        private Long attrId;
 | 
			
		||||
 | 
			
		||||
        private String attrName;
 | 
			
		||||
 | 
			
		||||
        private List<String> attrValue;
 | 
			
		||||
 | 
			
		||||
        public Long getAttrId() {
 | 
			
		||||
            return attrId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setAttrId(Long attrId) {
 | 
			
		||||
            this.attrId = attrId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getAttrName() {
 | 
			
		||||
            return attrName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setAttrName(String attrName) {
 | 
			
		||||
            this.attrName = attrName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public List<String> getAttrValue() {
 | 
			
		||||
            return attrValue;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setAttrValue(List<String> attrValue) {
 | 
			
		||||
            this.attrValue = attrValue;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static class categoryVo {
 | 
			
		||||
 | 
			
		||||
        private Long categoryId;
 | 
			
		||||
 | 
			
		||||
        private String categoryName;
 | 
			
		||||
 | 
			
		||||
        public Long getCategoryId() {
 | 
			
		||||
            return categoryId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setCategoryId(Long categoryId) {
 | 
			
		||||
            this.categoryId = categoryId;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public String getCategoryName() {
 | 
			
		||||
            return categoryName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public void setCategoryName(String categoryName) {
 | 
			
		||||
            this.categoryName = categoryName;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										550
									
								
								tulingmall-search/src/main/resources/ES检索数据优化.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										550
									
								
								tulingmall-search/src/main/resources/ES检索数据优化.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,550 @@
 | 
			
		||||
PUT /product_db/_doc/1
 | 
			
		||||
{
 | 
			
		||||
  "id": "26",
 | 
			
		||||
  "name": "С<><D0A1> 11 <20>ֻ<EFBFBD>",
 | 
			
		||||
  "keywords": "С<><D0A1><EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "AI<41>ǻ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD> 6GB +64GB <20><><EFBFBD><EFBFBD>ɫ ȫ<><C8AB>ͨ<EFBFBD><CDA8> <20>ƶ<EFBFBD><C6B6><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>4G<34>ֻ<EFBFBD> ˫<><CBAB>˫<EFBFBD><CBAB> ˫<><CBAB>˫<EFBFBD><CBAB>",
 | 
			
		||||
  "price": "3999",
 | 
			
		||||
  "promotionPrice": "2999",
 | 
			
		||||
  "originalPrice": "5999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":999,
 | 
			
		||||
  "putawayDate":"2021-04-01",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "С<><D0A1>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "2<><32>"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PUT /product_db/_doc/2
 | 
			
		||||
{
 | 
			
		||||
  "id": "27",
 | 
			
		||||
  "name": "С<><D0A1> 10 <20>ֻ<EFBFBD>",
 | 
			
		||||
  "keywords": "С<><D0A1><EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "AI<41>ǻ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD> 4GB +64GB <20><><EFBFBD><EFBFBD>ɫ ȫ<><C8AB>ͨ<EFBFBD><CDA8> <20>ƶ<EFBFBD><C6B6><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>4G<34>ֻ<EFBFBD> ˫<><CBAB>˫<EFBFBD><CBAB> ˫<><CBAB>˫<EFBFBD><CBAB>",
 | 
			
		||||
  "price": "2999",
 | 
			
		||||
  "promotionPrice": "1999",
 | 
			
		||||
  "originalPrice": "3999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": false,
 | 
			
		||||
  "salecount":99,
 | 
			
		||||
  "putawayDate":"2021-04-02",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "С<><D0A1>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "4<><34>"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/3
 | 
			
		||||
{
 | 
			
		||||
  "id": "28",
 | 
			
		||||
  "name": "С<><D0A1>  <20>ֻ<EFBFBD>",
 | 
			
		||||
  "keywords": "С<><D0A1><EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "AI<41>ǻ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD> 4GB +64GB <20><><EFBFBD><EFBFBD>ɫ ȫ<><C8AB>ͨ<EFBFBD><CDA8> <20>ƶ<EFBFBD><C6B6><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>4G<34>ֻ<EFBFBD> ˫<><CBAB>˫<EFBFBD><CBAB> ˫<><CBAB>˫<EFBFBD><CBAB>",
 | 
			
		||||
  "price": "2999",
 | 
			
		||||
  "promotionPrice": "1999",
 | 
			
		||||
  "originalPrice": "3999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":199,
 | 
			
		||||
  "putawayDate":"2021-04-03",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "С<><D0A1>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "2<><32>"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/4
 | 
			
		||||
{
 | 
			
		||||
  "id": "29",
 | 
			
		||||
  "name": "Apple iPhone 8 Plus 64GB <20><>ɫ<EFBFBD>ر<EFBFBD><D8B1><EFBFBD> <20>ƶ<EFBFBD><C6B6><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>4G<34>ֻ<EFBFBD>",
 | 
			
		||||
  "keywords": "ƻ<><C6BB><EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "ƻ<><C6BB><EFBFBD>ֻ<EFBFBD> Apple<6C><65>Ʒ<EFBFBD><C6B7><EFBFBD>пڣ<F1BBB6BD><DAA3><EFBFBD><EFBFBD>ᄀ<EFBFBD><EFBEA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǻۣ<C7BB><DBA3><EFBFBD><EFBFBD><EFBFBD> >> <20><>ѡ[<5B><><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>][ԭ<><D4AD><EFBFBD><EFBFBD>2<EFBFBD><32>]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>AppleCare+ȫ<><C8AB>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>ӱ<EFBFBD><D3B1>ۺ<EFBFBD><DBBA><EFBFBD><EFBFBD>ǡ<EFBFBD>",
 | 
			
		||||
  "price": "5999",
 | 
			
		||||
  "promotionPrice": "4999",
 | 
			
		||||
  "originalPrice": "7999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5acc5248N6a5f81cd.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":1199,
 | 
			
		||||
  "putawayDate":"2021-04-04",
 | 
			
		||||
  "brandId": 51,
 | 
			
		||||
  "brandName": "ƻ<><C6BB>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180607/timg.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "4<><34>"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/5
 | 
			
		||||
{
 | 
			
		||||
  "id": "30",
 | 
			
		||||
  "name": "HLA<4C><41><EFBFBD><EFBFBD>֮<EFBFBD>Ҽ<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><54>",
 | 
			
		||||
  "keywords": "<22><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>·<EFBFBD>",
 | 
			
		||||
  "subTitle": "HLA<4C><41><EFBFBD><EFBFBD>֮<EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>T<EFBFBD><54>",
 | 
			
		||||
  "price": "199",
 | 
			
		||||
  "promotionPrice": "99",
 | 
			
		||||
  "originalPrice": "299",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5ad83a4fN6ff67ecd.jpg!cc_350x449.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":19,
 | 
			
		||||
  "putawayDate":"2021-04-05",
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "<22><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T<><54>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 3,
 | 
			
		||||
      "attrName": "<22>ߴ<EFBFBD>",
 | 
			
		||||
      "attrValue": "M"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 4,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/6
 | 
			
		||||
{
 | 
			
		||||
  "id": "31",
 | 
			
		||||
  "name": "HLA<4C><41><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD>֯<EFBFBD><D6AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>T<EFBFBD><54>",
 | 
			
		||||
  "keywords": "<22><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>·<EFBFBD>",
 | 
			
		||||
  "subTitle": "HLA<4C><41><EFBFBD><EFBFBD>֮<EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>T<EFBFBD><54>",
 | 
			
		||||
  "price": "299",
 | 
			
		||||
  "promotionPrice": "199",
 | 
			
		||||
  "originalPrice": "299",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5ac98b64N70acd82f.jpg!cc_350x449.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":399,
 | 
			
		||||
  "putawayDate":"2021-04-06",
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "<22><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T<><54>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 3,
 | 
			
		||||
      "attrName": "<22>ߴ<EFBFBD>",
 | 
			
		||||
      "attrValue": "X"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 4,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><><EFBFBD><EFBFBD>"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/7
 | 
			
		||||
{
 | 
			
		||||
  "id": "32",
 | 
			
		||||
  "name": "HLA<4C><41><EFBFBD><EFBFBD>֮<EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>T<EFBFBD><54><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "keywords": "<22><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD>·<EFBFBD>",
 | 
			
		||||
  "subTitle": "HLA<4C><41><EFBFBD><EFBFBD>֮<EFBFBD>Ҷ<EFBFBD><D2B6><EFBFBD>T<EFBFBD><54>",
 | 
			
		||||
  "price": "269",
 | 
			
		||||
  "promotionPrice": "169",
 | 
			
		||||
  "originalPrice": "399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5a51eb88Na4797877.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":399,
 | 
			
		||||
  "putawayDate":"2021-04-07",
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "<22><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T<><54>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 3,
 | 
			
		||||
      "attrName": "<22>ߴ<EFBFBD>",
 | 
			
		||||
      "attrValue": "L"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 4,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/8
 | 
			
		||||
{
 | 
			
		||||
  "id": "33",
 | 
			
		||||
  "name": "С<>ף<EFBFBD>MI<4D><49>С<EFBFBD><EFBFBD><D7B5><EFBFBD>4A ",
 | 
			
		||||
  "keywords": "С<><EFBFBD><D7B5>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>",
 | 
			
		||||
  "subTitle": "С<>ף<EFBFBD>MI<4D><49>С<EFBFBD><EFBFBD><D7B5><EFBFBD>4A 55Ӣ<35><D3A2> L55M5-AZ/L55M5-AD 2GB+8GB HDR 4K<34><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD><D2BA>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "price": "2269",
 | 
			
		||||
  "promotionPrice": "2169",
 | 
			
		||||
  "originalPrice": "2399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b02804dN66004d73.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":132,
 | 
			
		||||
  "putawayDate":"2021-04-09",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "С<><D0A1>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 35,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 5,
 | 
			
		||||
      "attrName": "<22><>Ļ<EFBFBD>ߴ<EFBFBD>",
 | 
			
		||||
      "attrValue": "52"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 6,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/9
 | 
			
		||||
{
 | 
			
		||||
  "id": "34",
 | 
			
		||||
  "name": "С<>ף<EFBFBD>MI<4D><49>С<EFBFBD><EFBFBD><D7B5><EFBFBD>4A 65Ӣ<35><D3A2>",
 | 
			
		||||
  "keywords": "С<><EFBFBD><D7B5>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>",
 | 
			
		||||
  "subTitle": "С<>ף<EFBFBD>MI<4D><49>С<EFBFBD><EFBFBD><D7B5><EFBFBD>4A 65Ӣ<35><D3A2> L55M5-AZ/L55M5-AD 2GB+8GB HDR 4K<34><4B><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˹<EFBFBD><CBB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Һ<EFBFBD><D2BA>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "price": "3269",
 | 
			
		||||
  "promotionPrice": "3169",
 | 
			
		||||
  "originalPrice": "3399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b028530N51eee7d4.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":999,
 | 
			
		||||
  "putawayDate":"2021-04-10",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "С<><D0A1>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 35,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 5,
 | 
			
		||||
      "attrName": "<22><>Ļ<EFBFBD>ߴ<EFBFBD>",
 | 
			
		||||
      "attrValue": "65"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 6,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/10
 | 
			
		||||
{
 | 
			
		||||
  "id": "35",
 | 
			
		||||
  "name": "<22>Ϳ<EFBFBD>NIKE <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ь ROSHE RUN <20>˶<EFBFBD>Ь 511881-010<31><30>ɫ41<34><31>",
 | 
			
		||||
  "keywords": "<22>Ϳ<EFBFBD><CDBF>˶<EFBFBD>Ь Ь<><D0AC>",
 | 
			
		||||
  "subTitle": "<22>Ϳ<EFBFBD>NIKE <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ь ROSHE RUN <20>˶<EFBFBD>Ь 511881-010<31><30>ɫ41<34><31>",
 | 
			
		||||
  "price": "569",
 | 
			
		||||
  "promotionPrice": "369",
 | 
			
		||||
  "originalPrice": "899",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b235bb9Nf606460b.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":399,
 | 
			
		||||
  "putawayDate":"2021-04-11",
 | 
			
		||||
  "brandId": 58,
 | 
			
		||||
  "brandName": "NIKE",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/timg (51).jpg",
 | 
			
		||||
  "categoryId": 29,
 | 
			
		||||
  "categoryName": "<22><>Ь",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 7,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "42"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 8,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/11
 | 
			
		||||
{
 | 
			
		||||
  "id": "36",
 | 
			
		||||
  "name": "<22>Ϳ<EFBFBD>NIKE <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ь AIR MAX 90 ESSENTIAL <20>˶<EFBFBD>Ь AJ1285-101<30><31>ɫ41<34><31>",
 | 
			
		||||
  "keywords": "<22>Ϳ<EFBFBD><CDBF>˶<EFBFBD>Ь Ь<><D0AC>",
 | 
			
		||||
  "subTitle": "AIR MAX 90 ESSENTIAL <20>˶<EFBFBD>Ь AJ1285-101<30><31>ɫ",
 | 
			
		||||
  "price": "769",
 | 
			
		||||
  "promotionPrice": "469",
 | 
			
		||||
  "originalPrice": "999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b19403eN9f0b3cb8.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":499,
 | 
			
		||||
  "putawayDate":"2021-04-13",
 | 
			
		||||
  "brandId": 58,
 | 
			
		||||
  "brandName": "NIKE",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/timg (51).jpg",
 | 
			
		||||
  "categoryId": 29,
 | 
			
		||||
  "categoryName": "<22><>Ь",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 7,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "44"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 8,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/12
 | 
			
		||||
{
 | 
			
		||||
  "id": "37",
 | 
			
		||||
  "name": "(<28><>Ϊ)HUAWEI MateBook X Pro 2019<31><39> 13.9Ӣ<EFBFBD><EFBFBD>3K<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ᱡ<EFBFBD>ʼDZ<CABC>",
 | 
			
		||||
  "keywords": "<22>ᱡ<EFBFBD>ʼDZ<CABC><C7B1><EFBFBD>Ϊ <20>ʼDZ<CABC><C7B1><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "subTitle": "<22>ᱡ<EFBFBD><E1B1A1>Ϊ<EFBFBD>ʼDZ<CABC> <20><><EFBFBD><EFBFBD>",
 | 
			
		||||
  "price": "4769",
 | 
			
		||||
  "promotionPrice": "4469",
 | 
			
		||||
  "originalPrice": "4999",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200317/800_800_1555752016264mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":699,
 | 
			
		||||
  "putawayDate":"2021-04-14",
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "<22><>Ϊ",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 9,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "16G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 10,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "4G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/13
 | 
			
		||||
{
 | 
			
		||||
  "id": "38",
 | 
			
		||||
  "name": "<22><>Ϊnova6se <20>ֻ<EFBFBD> 精<>ɭ<EFBFBD><C9AD> ȫ<><C8AB>ͨ<EFBFBD><CDA8>8G+128G)",
 | 
			
		||||
  "keywords": "<22>ᱡ<EFBFBD>ʼDZ<CABC><C7B1><EFBFBD>Ϊ <20>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "<22><>Ϊnova6se <20>ֻ<EFBFBD>",
 | 
			
		||||
  "price": "6769",
 | 
			
		||||
  "promotionPrice": "6469",
 | 
			
		||||
  "originalPrice": "6999",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/78_78_42B09549789695A42D621CF87DC53B5EBE9385772DC61FB9mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":899,
 | 
			
		||||
  "putawayDate":"2021-04-15",
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "<22><>Ϊ",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 9,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "64G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 10,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "5G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/14
 | 
			
		||||
{
 | 
			
		||||
  "id": "39",
 | 
			
		||||
  "name": "iPhone7/6s/8<>ֻ<EFBFBD>Ĥƻ<C4A4><C6BB>8Plusȫ<73><C8AB><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>ֻ<EFBFBD>Ĥ",
 | 
			
		||||
  "keywords": "<22>ֻ<EFBFBD>Ĥ",
 | 
			
		||||
  "subTitle": "iPhone7/6s/8<>ֻ<EFBFBD>Ĥƻ<C4A4><C6BB>8Plusȫ<73><C8AB><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>ֻ<EFBFBD>Ĥ",
 | 
			
		||||
  "price": "29",
 | 
			
		||||
  "promotionPrice": "39",
 | 
			
		||||
  "originalPrice": "49",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/6df99dab78bb2014.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":799,
 | 
			
		||||
  "putawayDate":"2021-04-16",
 | 
			
		||||
  "brandId": 51,
 | 
			
		||||
  "brandName": "ƻ<><C6BB>",
 | 
			
		||||
  "brandImg": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/2b84746650fc122d67749a876c453619.png",
 | 
			
		||||
  "categoryId": 30,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 11,
 | 
			
		||||
      "attrName": "<22>ֻ<EFBFBD>Ĥ-<2D><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "<22>ֻ<EFBFBD>"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 12,
 | 
			
		||||
      "attrName": "<22>ֻ<EFBFBD>Ĥ-<2D><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/15
 | 
			
		||||
{
 | 
			
		||||
  "id": "40",
 | 
			
		||||
  "name": "<22><>ƥ<EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>T<EFBFBD><54><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD><CAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ Բ<><D4B2>3<EFBFBD><33>װ",
 | 
			
		||||
  "keywords": "<22><>ƥ<EFBFBD>Ƿ<EFBFBD>װ <20>·<EFBFBD>",
 | 
			
		||||
  "subTitle": "<22><>ƥ<EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>T<EFBFBD><54><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʴ<EFBFBD><CAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ Բ<><D4B2>3<EFBFBD><33>װ",
 | 
			
		||||
  "price": "129",
 | 
			
		||||
  "promotionPrice": "139",
 | 
			
		||||
  "originalPrice": "149",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/19e846e727dff337.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":199,
 | 
			
		||||
  "putawayDate":"2021-04-20",
 | 
			
		||||
  "brandId": 49,
 | 
			
		||||
  "brandName": "<22><>ƥ<EFBFBD><C6A5>",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/18d8bc3eb13533fab466d702a0d3fd1f40345bcd.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T<><54>",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 3,
 | 
			
		||||
      "attrName": "<22>ߴ<EFBFBD>",
 | 
			
		||||
      "attrValue": "M"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 4,
 | 
			
		||||
      "attrName": "<22><>ɫ",
 | 
			
		||||
      "attrValue": "<22><>ɫ"
 | 
			
		||||
    },
 | 
			
		||||
     {
 | 
			
		||||
      "attrId": 13,
 | 
			
		||||
      "attrName": "<22><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD>",
 | 
			
		||||
      "attrValue": "<22><><EFBFBD><EFBFBD>"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/16
 | 
			
		||||
{
 | 
			
		||||
  "id": "41",
 | 
			
		||||
  "name": "<22><>ΪP40 Pro<72>ֻ<EFBFBD>",
 | 
			
		||||
  "keywords": "<22><>Ϊ<EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "<22><>ΪP40 Pro<72>ֻ<EFBFBD>",
 | 
			
		||||
  "price": "2129",
 | 
			
		||||
  "promotionPrice": "2139",
 | 
			
		||||
  "originalPrice": "2149",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200327/1_DE7F785A7E0C276D3A1F40A5C6D82B07D2AED60CE1F73795mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":199,
 | 
			
		||||
  "putawayDate":"2021-05-03",
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "<22><>Ϊ",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 9,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "128G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 10,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "5G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/17
 | 
			
		||||
{
 | 
			
		||||
  "id": "42",
 | 
			
		||||
  "name": "<22><>Ψ<EFBFBD><CEA8><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD> 4Gȫ<47><C8AB>ͨ <20><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7>˫<EFBFBD><CBAB>˫<EFBFBD><CBAB><EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "keywords": "<22><>Ψ<EFBFBD>ֻ<EFBFBD>",
 | 
			
		||||
  "subTitle": "<22><>Ψ<EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>˫<EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>оƬ<D0BE><C6AC><EFBFBD>Ż<EFBFBD>ɢ<EFBFBD>Ƚṹ<C8BD><E1B9B9>dz<EFBFBD><C7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψ4<CEA8><34><EFBFBD>ػݣ<D8BB>",
 | 
			
		||||
  "price": "3129",
 | 
			
		||||
  "promotionPrice": "3139",
 | 
			
		||||
  "originalPrice": "3249",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":1199,
 | 
			
		||||
  "putawayDate":"2021-06-01",
 | 
			
		||||
  "brandId": 59,
 | 
			
		||||
  "brandName": "<22><>Ψ",
 | 
			
		||||
  "brandImg": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/2b84746650fc122d67749a876c453619.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "<22>ֻ<EFBFBD>ͨѶ",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 9,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "32G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 10,
 | 
			
		||||
      "attrName": "<22><><EFBFBD><EFBFBD>",
 | 
			
		||||
      "attrValue": "4G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										47
									
								
								tulingmall-search/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								tulingmall-search/src/main/resources/application.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
server:
 | 
			
		||||
  port: 8054
 | 
			
		||||
spring:
 | 
			
		||||
  datasource:
 | 
			
		||||
    url: jdbc:mysql://192.168.65.71:3306/tl_mall_goods?characterEncoding=utf-8&useSSL=false
 | 
			
		||||
    driver-class-name: com.mysql.cj.jdbc.Driver
 | 
			
		||||
    username: tlmall
 | 
			
		||||
    password: tlmall123
 | 
			
		||||
    druid:
 | 
			
		||||
      initial-size: 5 #连接池初始化大小
 | 
			
		||||
      min-idle: 10 #最小空闲连接数
 | 
			
		||||
      max-active: 20 #最大连接数
 | 
			
		||||
      web-stat-filter:
 | 
			
		||||
        exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" #不统计这些请求数据
 | 
			
		||||
      stat-view-servlet: #访问监控网页的登录用户名和密码
 | 
			
		||||
        login-username: druid
 | 
			
		||||
        login-password: druid
 | 
			
		||||
 | 
			
		||||
#  data:
 | 
			
		||||
#    elasticsearch:
 | 
			
		||||
#      repositories:
 | 
			
		||||
#        enabled: true
 | 
			
		||||
#      cluster-nodes: tl.es.com:9300
 | 
			
		||||
#      cluster-name: elasticsearch
 | 
			
		||||
  application:
 | 
			
		||||
    name: tulingmall-search
 | 
			
		||||
  cloud:
 | 
			
		||||
    nacos:
 | 
			
		||||
      discovery:
 | 
			
		||||
        server-addr: 192.168.65.206:8848,192.168.65.209:8848,192.168.65.210:8848
 | 
			
		||||
#  data:
 | 
			
		||||
#    elasticsearch:
 | 
			
		||||
#      rest:
 | 
			
		||||
#        #uris: 192.168.21.110:9300,192.168.21.113:9300,192.168.21.219:9300
 | 
			
		||||
#        uris: 192.168.21.219:9300
 | 
			
		||||
#        username: elastic
 | 
			
		||||
#        password: 123456
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
mybatis:
 | 
			
		||||
  mapper-locations:
 | 
			
		||||
    - classpath:dao/*.xml
 | 
			
		||||
    - classpath*:com/**/mapper/*.xml
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								tulingmall-search/src/main/resources/bootstrap.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								tulingmall-search/src/main/resources/bootstrap.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
spring:
 | 
			
		||||
  application:
 | 
			
		||||
    name: tulingmall-search
 | 
			
		||||
  cloud:
 | 
			
		||||
    nacos:
 | 
			
		||||
      config:
 | 
			
		||||
        server-addr: 192.168.65.206:8848,192.168.65.209:8848,192.168.65.210:8848 #配置中心的地址
 | 
			
		||||
        file-extension: yml #配置文件结尾的配置
 | 
			
		||||
        shared-configs[0]:
 | 
			
		||||
          data-id: tulingmall-nacos.yml
 | 
			
		||||
          group: DEFAULT_GROUP
 | 
			
		||||
          refresh: true
 | 
			
		||||
  profiles:
 | 
			
		||||
    active: dev
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
logging:
 | 
			
		||||
  level:
 | 
			
		||||
    com:
 | 
			
		||||
      tuling:
 | 
			
		||||
        tulingmall:
 | 
			
		||||
          dao: debug
 | 
			
		||||
							
								
								
									
										46
									
								
								tulingmall-search/src/main/resources/dao/EsProductDao.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								tulingmall-search/src/main/resources/dao/EsProductDao.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 | 
			
		||||
<mapper namespace="com.tuling.tulingmall.search.dao.EsProductDao">
 | 
			
		||||
    <resultMap id="esProductListMap" type="com.tuling.tulingmall.search.domain.EsProduct" autoMapping="true">
 | 
			
		||||
        <id column="id" jdbcType="BIGINT" property="id" />
 | 
			
		||||
        <collection property="attrValueList" columnPrefix="attr_" ofType="com.tuling.tulingmall.search.domain.EsProductAttributeValue">
 | 
			
		||||
            <id column="id" property="id" jdbcType="BIGINT"/>
 | 
			
		||||
            <result column="product_attribute_id" property="productAttributeId" jdbcType="BIGINT"/>
 | 
			
		||||
            <result column="value" property="value" jdbcType="VARCHAR"/>
 | 
			
		||||
            <result column="type" property="type"/>
 | 
			
		||||
            <result column="name" property="name"/>
 | 
			
		||||
        </collection>
 | 
			
		||||
    </resultMap>
 | 
			
		||||
    <select id="getAllEsProductList" resultMap="esProductListMap">
 | 
			
		||||
        select
 | 
			
		||||
            p.id id,
 | 
			
		||||
            p.product_sn productSn,
 | 
			
		||||
            p.brand_id brandId,
 | 
			
		||||
            p.brand_name brandName,
 | 
			
		||||
            p.product_category_id productCategoryId,
 | 
			
		||||
            p.product_category_name productCategoryName,
 | 
			
		||||
            p.pic pic,
 | 
			
		||||
            p.name name,
 | 
			
		||||
            p.sub_title subTitle,
 | 
			
		||||
            p.price price,
 | 
			
		||||
            p.sale sale,
 | 
			
		||||
            p.new_status newStatus,
 | 
			
		||||
            p.recommand_status recommandStatus,
 | 
			
		||||
            p.stock stock,
 | 
			
		||||
            p.promotion_type promotionType,
 | 
			
		||||
            p.keywords keywords,
 | 
			
		||||
            p.sort sort,
 | 
			
		||||
            pav.id attr_id,
 | 
			
		||||
            pav.value attr_value,
 | 
			
		||||
            pav.product_attribute_id attr_product_attribute_id,
 | 
			
		||||
            pa.type attr_type,
 | 
			
		||||
            pa.name attr_name
 | 
			
		||||
        from tl_mall_goods.pms_product p
 | 
			
		||||
        left join tl_mall_goods.pms_product_attribute_value pav on p.id = pav.product_id
 | 
			
		||||
        left join tl_mall_goods.pms_product_attribute pa on pav.product_attribute_id= pa.id
 | 
			
		||||
        where delete_status = 0 and publish_status = 1
 | 
			
		||||
        <if test="id!=null">
 | 
			
		||||
            and p.id=#{id}
 | 
			
		||||
        </if>
 | 
			
		||||
    </select>
 | 
			
		||||
</mapper>
 | 
			
		||||
							
								
								
									
										698
									
								
								tulingmall-search/src/main/resources/data
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										698
									
								
								tulingmall-search/src/main/resources/data
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,698 @@
 | 
			
		||||
/****************创建索引库******************/
 | 
			
		||||
PUT product_db
 | 
			
		||||
{
 | 
			
		||||
  "mappings": {
 | 
			
		||||
    "properties": {
 | 
			
		||||
      "id": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "name": {
 | 
			
		||||
        "type": "text",
 | 
			
		||||
        "analyzer": "ik_max_word"
 | 
			
		||||
      },
 | 
			
		||||
      "keywords": {
 | 
			
		||||
        "type": "text",
 | 
			
		||||
        "analyzer": "ik_max_word"
 | 
			
		||||
      },
 | 
			
		||||
      "subTitle": {
 | 
			
		||||
        "type": "text",
 | 
			
		||||
        "analyzer": "ik_max_word"
 | 
			
		||||
      },
 | 
			
		||||
      "price": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "promotionPrice": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "originalPrice": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "pic": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "sale": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "stock": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "brandId": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "brandName": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "brandImg": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "categoryId": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "categoryName": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "attrs": {
 | 
			
		||||
        "type": "nested",
 | 
			
		||||
        "properties": {
 | 
			
		||||
          "attrId": {
 | 
			
		||||
            "type": "long"
 | 
			
		||||
          },
 | 
			
		||||
          "attrName": {
 | 
			
		||||
            "type": "keyword"
 | 
			
		||||
          },
 | 
			
		||||
          "attrValue": {
 | 
			
		||||
            "type": "keyword"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//查询
 | 
			
		||||
POST /product_db/_doc/_search
 | 
			
		||||
{
 | 
			
		||||
  "from": 0,
 | 
			
		||||
  "size": 8,
 | 
			
		||||
  "query": {
 | 
			
		||||
    "bool": {
 | 
			
		||||
      "must": [
 | 
			
		||||
        {
 | 
			
		||||
          "match": {
 | 
			
		||||
            "name": {
 | 
			
		||||
              "query": "华为"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "aggregations": {
 | 
			
		||||
    "brand_agg": {
 | 
			
		||||
      "terms": {
 | 
			
		||||
        "field": "brandId",
 | 
			
		||||
        "size": 50
 | 
			
		||||
      },
 | 
			
		||||
      "aggregations": {
 | 
			
		||||
        "brand_name_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "brandName",
 | 
			
		||||
            "size": 1,
 | 
			
		||||
            "min_doc_count": 1
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "brand_img_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "brandImg",
 | 
			
		||||
            "size": 1,
 | 
			
		||||
            "min_doc_count": 1,
 | 
			
		||||
            "shard_min_doc_count": 0,
 | 
			
		||||
            "show_term_doc_count_error": false,
 | 
			
		||||
            "order": [
 | 
			
		||||
              {
 | 
			
		||||
                "_count": "desc"
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "_key": "asc"
 | 
			
		||||
              }
 | 
			
		||||
            ]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "category_agg": {
 | 
			
		||||
      "terms": {
 | 
			
		||||
        "field": "categoryId",
 | 
			
		||||
        "size": 50,
 | 
			
		||||
        "min_doc_count": 1
 | 
			
		||||
      },
 | 
			
		||||
      "aggregations": {
 | 
			
		||||
        "category_name_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "categoryName",
 | 
			
		||||
            "size": 20
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "attr_agg": {
 | 
			
		||||
      "nested": {
 | 
			
		||||
        "path": "attrs"
 | 
			
		||||
      },
 | 
			
		||||
      "aggregations": {
 | 
			
		||||
        "attr_id_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "attrs.attrId",
 | 
			
		||||
            "size": 10,
 | 
			
		||||
            "min_doc_count": 1
 | 
			
		||||
          },
 | 
			
		||||
          "aggregations": {
 | 
			
		||||
            "attr_name_agg": {
 | 
			
		||||
              "terms": {
 | 
			
		||||
                "field": "attrs.attrName",
 | 
			
		||||
                "size": 1,
 | 
			
		||||
                "min_doc_count": 1
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            "attr_value_agg": {
 | 
			
		||||
              "terms": {
 | 
			
		||||
                "field": "attrs.attrValue",
 | 
			
		||||
                "size": 50,
 | 
			
		||||
                "min_doc_count": 1
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "highlight": {
 | 
			
		||||
    "pre_tags": [
 | 
			
		||||
      "<b style='color:red'>"
 | 
			
		||||
    ],
 | 
			
		||||
    "post_tags": [
 | 
			
		||||
      "</b>"
 | 
			
		||||
    ],
 | 
			
		||||
    "fields": {
 | 
			
		||||
      "name": {}
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//添加数据
 | 
			
		||||
PUT /product_db/_doc/1
 | 
			
		||||
{
 | 
			
		||||
  "id": "26",
 | 
			
		||||
  "name": "小米 11 手机",
 | 
			
		||||
  "keywords": "小米手机",
 | 
			
		||||
  "subTitle": "AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待",
 | 
			
		||||
  "price": "3999",
 | 
			
		||||
  "promotionPrice": "2999",
 | 
			
		||||
  "originalPrice": "5999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 12,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "2核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "黄色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PUT /product_db/_doc/2
 | 
			
		||||
{
 | 
			
		||||
  "id": "27",
 | 
			
		||||
  "name": "小米 10 手机",
 | 
			
		||||
  "keywords": "小米手机",
 | 
			
		||||
  "subTitle": "AI智慧全面屏 4GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待",
 | 
			
		||||
  "price": "2999",
 | 
			
		||||
  "promotionPrice": "1999",
 | 
			
		||||
  "originalPrice": "3999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 12,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "4核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/3
 | 
			
		||||
{
 | 
			
		||||
  "id": "28",
 | 
			
		||||
  "name": "小米  手机",
 | 
			
		||||
  "keywords": "小米手机",
 | 
			
		||||
  "subTitle": "AI智慧全面屏 4GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待",
 | 
			
		||||
  "price": "2999",
 | 
			
		||||
  "promotionPrice": "1999",
 | 
			
		||||
  "originalPrice": "3999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 12,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "2核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "蓝色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/4
 | 
			
		||||
{
 | 
			
		||||
  "id": "29",
 | 
			
		||||
  "name": "Apple iPhone 8 Plus 64GB 红色特别版 移动联通电信4G手机",
 | 
			
		||||
  "keywords": "苹果手机",
 | 
			
		||||
  "subTitle": "【限时限量抢购】Apple产品年中狂欢节,好物尽享,美在智慧!速来 >> 勾选[保障服务][原厂保2年],获得AppleCare+全方位服务计划,原厂延保售后无忧。",
 | 
			
		||||
  "price": "5999",
 | 
			
		||||
  "promotionPrice": "4999",
 | 
			
		||||
  "originalPrice": "7999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5acc5248N6a5f81cd.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 12,
 | 
			
		||||
  "brandName": "苹果",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180607/timg.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "4核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "金色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/5
 | 
			
		||||
{
 | 
			
		||||
  "id": "30",
 | 
			
		||||
  "name": "HLA海澜之家简约动物印花短袖T恤",
 | 
			
		||||
  "keywords": "海澜之家",
 | 
			
		||||
  "subTitle": "HLA海澜之家短袖T恤",
 | 
			
		||||
  "price": "199",
 | 
			
		||||
  "promotionPrice": "99",
 | 
			
		||||
  "originalPrice": "299",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5ad83a4fN6ff67ecd.jpg!cc_350x449.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "海澜之家",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "M"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "黑色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/6
 | 
			
		||||
{
 | 
			
		||||
  "id": "31",
 | 
			
		||||
  "name": "HLA海澜之家蓝灰花纹圆领针织布短袖T恤",
 | 
			
		||||
  "keywords": "海澜之家",
 | 
			
		||||
  "subTitle": "HLA海澜之家短袖T恤",
 | 
			
		||||
  "price": "299",
 | 
			
		||||
  "promotionPrice": "199",
 | 
			
		||||
  "originalPrice": "299",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5ac98b64N70acd82f.jpg!cc_350x449.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "海澜之家",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "X"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/7
 | 
			
		||||
{
 | 
			
		||||
  "id": "32",
 | 
			
		||||
  "name": "HLA海澜之家短袖T恤男基础款",
 | 
			
		||||
  "keywords": "海澜之家",
 | 
			
		||||
  "subTitle": "HLA海澜之家短袖T恤",
 | 
			
		||||
  "price": "269",
 | 
			
		||||
  "promotionPrice": "169",
 | 
			
		||||
  "originalPrice": "399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5a51eb88Na4797877.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "海澜之家",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "L"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "蓝色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/8
 | 
			
		||||
{
 | 
			
		||||
  "id": "33",
 | 
			
		||||
  "name": "小米(MI)小米电视4A ",
 | 
			
		||||
  "keywords": "小米电视机",
 | 
			
		||||
  "subTitle": "小米(MI)小米电视4A 55英寸 L55M5-AZ/L55M5-AD 2GB+8GB HDR 4K超高清 人工智能网络液晶平板电视",
 | 
			
		||||
  "price": "2269",
 | 
			
		||||
  "promotionPrice": "2169",
 | 
			
		||||
  "originalPrice": "2399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b02804dN66004d73.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 35,
 | 
			
		||||
  "categoryName": "手机数码",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "屏幕尺寸",
 | 
			
		||||
      "attrValue": "52"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "机身颜色",
 | 
			
		||||
      "attrValue": "黑色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/9
 | 
			
		||||
{
 | 
			
		||||
  "id": "34",
 | 
			
		||||
  "name": "小米(MI)小米电视4A 65英寸",
 | 
			
		||||
  "keywords": "小米电视机",
 | 
			
		||||
  "subTitle": "小米(MI)小米电视4A 65英寸 L55M5-AZ/L55M5-AD 2GB+8GB HDR 4K超高清 人工智能网络液晶平板电视",
 | 
			
		||||
  "price": "3269",
 | 
			
		||||
  "promotionPrice": "3169",
 | 
			
		||||
  "originalPrice": "3399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b028530N51eee7d4.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 35,
 | 
			
		||||
  "categoryName": "手机数码",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "屏幕尺寸",
 | 
			
		||||
      "attrValue": "65"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "机身颜色",
 | 
			
		||||
      "attrValue": "金色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/10
 | 
			
		||||
{
 | 
			
		||||
  "id": "35",
 | 
			
		||||
  "name": "耐克NIKE 男子 休闲鞋 ROSHE RUN 运动鞋 511881-010黑色41码",
 | 
			
		||||
  "keywords": "耐克运动鞋",
 | 
			
		||||
  "subTitle": "耐克NIKE 男子 休闲鞋 ROSHE RUN 运动鞋 511881-010黑色41码",
 | 
			
		||||
  "price": "569",
 | 
			
		||||
  "promotionPrice": "369",
 | 
			
		||||
  "originalPrice": "899",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b235bb9Nf606460b.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 58,
 | 
			
		||||
  "brandName": "NIKE",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/timg (51).jpg",
 | 
			
		||||
  "categoryId": 29,
 | 
			
		||||
  "categoryName": "男鞋",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺码",
 | 
			
		||||
      "attrValue": "42"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/11
 | 
			
		||||
{
 | 
			
		||||
  "id": "36",
 | 
			
		||||
  "name": "耐克NIKE 男子 气垫 休闲鞋 AIR MAX 90 ESSENTIAL 运动鞋 AJ1285-101白色41码",
 | 
			
		||||
  "keywords": "耐克运动鞋",
 | 
			
		||||
  "subTitle": "AIR MAX 90 ESSENTIAL 运动鞋 AJ1285-101白色",
 | 
			
		||||
  "price": "769",
 | 
			
		||||
  "promotionPrice": "469",
 | 
			
		||||
  "originalPrice": "999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b19403eN9f0b3cb8.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 58,
 | 
			
		||||
  "brandName": "NIKE",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/timg (51).jpg",
 | 
			
		||||
  "categoryId": 29,
 | 
			
		||||
  "categoryName": "男鞋",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺码",
 | 
			
		||||
      "attrValue": "44"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/12
 | 
			
		||||
{
 | 
			
		||||
  "id": "37",
 | 
			
		||||
  "name": "(华为)HUAWEI MateBook X Pro 2019款 13.9英寸3K触控全面屏 轻薄笔记本",
 | 
			
		||||
  "keywords": "轻薄笔记本华为",
 | 
			
		||||
  "subTitle": "轻薄笔记本",
 | 
			
		||||
  "price": "4769",
 | 
			
		||||
  "promotionPrice": "4469",
 | 
			
		||||
  "originalPrice": "4999",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200317/800_800_1555752016264mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "华为",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "16G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "4G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/13
 | 
			
		||||
{
 | 
			
		||||
  "id": "38",
 | 
			
		||||
  "name": "华为nova6se 手机 绮境森林 全网通(8G+128G)",
 | 
			
		||||
  "keywords": "轻薄笔记本华为",
 | 
			
		||||
  "subTitle": "华为nova6se 手机",
 | 
			
		||||
  "price": "6769",
 | 
			
		||||
  "promotionPrice": "6469",
 | 
			
		||||
  "originalPrice": "6999",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/78_78_42B09549789695A42D621CF87DC53B5EBE9385772DC61FB9mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "华为",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "64G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "5G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/14
 | 
			
		||||
{
 | 
			
		||||
  "id": "39",
 | 
			
		||||
  "name": "iPhone7/6s/8钢化膜苹果8Plus全屏复盖抗蓝光防窥防偷看手机膜",
 | 
			
		||||
  "keywords": "手机膜",
 | 
			
		||||
  "subTitle": "iPhone7/6s/8钢化膜苹果8Plus全屏复盖抗蓝光防窥防偷看手机膜",
 | 
			
		||||
  "price": "29",
 | 
			
		||||
  "promotionPrice": "39",
 | 
			
		||||
  "originalPrice": "49",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/6df99dab78bb2014.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "朵唯",
 | 
			
		||||
  "brandImg": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/2b84746650fc122d67749a876c453619.png",
 | 
			
		||||
  "categoryId": 30,
 | 
			
		||||
  "categoryName": "手机配件",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "手机膜-材料",
 | 
			
		||||
      "attrValue": "钢化"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "手机膜-颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/15
 | 
			
		||||
{
 | 
			
		||||
  "id": "40",
 | 
			
		||||
  "name": "七匹狼短袖T恤男纯棉舒适春夏修身运动休闲短袖三条装 圆领3条装",
 | 
			
		||||
  "keywords": "七匹狼服装",
 | 
			
		||||
  "subTitle": "七匹狼短袖T恤男纯棉舒适春夏修身运动休闲短袖三条装 圆领3条装",
 | 
			
		||||
  "price": "129",
 | 
			
		||||
  "promotionPrice": "139",
 | 
			
		||||
  "originalPrice": "149",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/19e846e727dff337.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 49,
 | 
			
		||||
  "brandName": "七匹狼",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/18d8bc3eb13533fab466d702a0d3fd1f40345bcd.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "M"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    },
 | 
			
		||||
     {
 | 
			
		||||
      "attrId": 3,
 | 
			
		||||
      "attrName": "适用季节",
 | 
			
		||||
      "attrValue": "春季"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/16
 | 
			
		||||
{
 | 
			
		||||
  "id": "41",
 | 
			
		||||
  "name": "华为P40 Pro",
 | 
			
		||||
  "keywords": "华为手机",
 | 
			
		||||
  "subTitle": "华为P40 Pro",
 | 
			
		||||
  "price": "2129",
 | 
			
		||||
  "promotionPrice": "2139",
 | 
			
		||||
  "originalPrice": "2149",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200327/1_DE7F785A7E0C276D3A1F40A5C6D82B07D2AED60CE1F73795mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "华为",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "128G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "5G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/17
 | 
			
		||||
{
 | 
			
		||||
  "id": "42",
 | 
			
		||||
  "name": "朵唯智能手机 4G全网通 老人学生双卡双待手机",
 | 
			
		||||
  "keywords": "朵唯手机",
 | 
			
		||||
  "subTitle": "后置双摄,国产虎贲芯片!优化散热结构!浅薄机身!朵唯4月特惠!",
 | 
			
		||||
  "price": "3129",
 | 
			
		||||
  "promotionPrice": "3139",
 | 
			
		||||
  "originalPrice": "3149",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "stock": 100000,
 | 
			
		||||
  "brandId": 59,
 | 
			
		||||
  "brandName": "朵唯",
 | 
			
		||||
  "brandImg": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/2b84746650fc122d67749a876c453619.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "32G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "4G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										719
									
								
								tulingmall-search/src/main/resources/new_product_mapping.text
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										719
									
								
								tulingmall-search/src/main/resources/new_product_mapping.text
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,719 @@
 | 
			
		||||
//创建索引库
 | 
			
		||||
PUT product_db
 | 
			
		||||
{
 | 
			
		||||
  "mappings": {
 | 
			
		||||
    "properties": {
 | 
			
		||||
      "id": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "name": {
 | 
			
		||||
        "type": "text",
 | 
			
		||||
        "analyzer": "ik_max_word"
 | 
			
		||||
      },
 | 
			
		||||
      "keywords": {
 | 
			
		||||
        "type": "text",
 | 
			
		||||
        "analyzer": "ik_max_word"
 | 
			
		||||
      },
 | 
			
		||||
      "subTitle": {
 | 
			
		||||
        "type": "text",
 | 
			
		||||
        "analyzer": "ik_max_word"
 | 
			
		||||
      },
 | 
			
		||||
      "salecount":{
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
       "putawayDate":{
 | 
			
		||||
        "type": "date"
 | 
			
		||||
      },
 | 
			
		||||
      "price": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
 | 
			
		||||
      "promotionPrice": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "originalPrice": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "pic": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "sale": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "hasStock": {
 | 
			
		||||
        "type": "boolean"
 | 
			
		||||
      },
 | 
			
		||||
      "brandId": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "brandName": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "brandImg": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "categoryId": {
 | 
			
		||||
        "type": "long"
 | 
			
		||||
      },
 | 
			
		||||
      "categoryName": {
 | 
			
		||||
        "type": "keyword"
 | 
			
		||||
      },
 | 
			
		||||
      "attrs": {
 | 
			
		||||
        "type": "nested",
 | 
			
		||||
        "properties": {
 | 
			
		||||
          "attrId": {
 | 
			
		||||
            "type": "long"
 | 
			
		||||
          },
 | 
			
		||||
          "attrName": {
 | 
			
		||||
            "type": "keyword"
 | 
			
		||||
          },
 | 
			
		||||
          "attrValue": {
 | 
			
		||||
            "type": "keyword"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//检索
 | 
			
		||||
POST /product_db/_doc/_search
 | 
			
		||||
{
 | 
			
		||||
  "from": 0,
 | 
			
		||||
  "size": 8,
 | 
			
		||||
  "query": {
 | 
			
		||||
    "bool": {
 | 
			
		||||
      "must": [
 | 
			
		||||
        {
 | 
			
		||||
          "match": {
 | 
			
		||||
            "name": {
 | 
			
		||||
              "query": "华为手机"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      ]
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "aggregations": {
 | 
			
		||||
    "brand_agg": {
 | 
			
		||||
      "terms": {
 | 
			
		||||
        "field": "brandId",
 | 
			
		||||
        "size": 50
 | 
			
		||||
      },
 | 
			
		||||
      "aggregations": {
 | 
			
		||||
        "brand_name_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "brandName"
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        "brand_img_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "brandImg"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "category_agg": {
 | 
			
		||||
      "terms": {
 | 
			
		||||
        "field": "categoryId",
 | 
			
		||||
        "size": 50,
 | 
			
		||||
        "min_doc_count": 1
 | 
			
		||||
      },
 | 
			
		||||
      "aggregations": {
 | 
			
		||||
        "category_name_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "categoryName"
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "attr_agg": {
 | 
			
		||||
      "nested": {
 | 
			
		||||
        "path": "attrs"
 | 
			
		||||
      },
 | 
			
		||||
      "aggregations": {
 | 
			
		||||
        "attr_id_agg": {
 | 
			
		||||
          "terms": {
 | 
			
		||||
            "field": "attrs.attrId"
 | 
			
		||||
          },
 | 
			
		||||
          "aggregations": {
 | 
			
		||||
            "attr_name_agg": {
 | 
			
		||||
              "terms": {
 | 
			
		||||
                "field": "attrs.attrName"
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            "attr_value_agg": {
 | 
			
		||||
              "terms": {
 | 
			
		||||
                "field": "attrs.attrValue"
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "highlight": {
 | 
			
		||||
    "pre_tags": [
 | 
			
		||||
      "<b style='color:red'>"
 | 
			
		||||
    ],
 | 
			
		||||
    "post_tags": [
 | 
			
		||||
      "</b>"
 | 
			
		||||
    ],
 | 
			
		||||
    "fields": {
 | 
			
		||||
      "name": {}
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//添加数据
 | 
			
		||||
PUT /product_db/_doc/1
 | 
			
		||||
{
 | 
			
		||||
  "id": "26",
 | 
			
		||||
  "name": "小米 11 手机",
 | 
			
		||||
  "keywords": "小米手机",
 | 
			
		||||
  "subTitle": "AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待 双卡双待",
 | 
			
		||||
  "price": "3999",
 | 
			
		||||
  "promotionPrice": "2999",
 | 
			
		||||
  "originalPrice": "5999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":999,
 | 
			
		||||
  "putawayDate":"2021-04-01",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "2核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "黑色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PUT /product_db/_doc/2
 | 
			
		||||
{
 | 
			
		||||
  "id": "27",
 | 
			
		||||
  "name": "小米 10 手机",
 | 
			
		||||
  "keywords": "小米手机",
 | 
			
		||||
  "subTitle": "AI智慧全面屏 4GB +64GB 亮白色 全网通版 移动联通电信4G手机 双卡双待 双卡双待",
 | 
			
		||||
  "price": "2999",
 | 
			
		||||
  "promotionPrice": "1999",
 | 
			
		||||
  "originalPrice": "3999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": false,
 | 
			
		||||
  "salecount":99,
 | 
			
		||||
  "putawayDate":"2021-04-02",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "4核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/3
 | 
			
		||||
{
 | 
			
		||||
  "id": "28",
 | 
			
		||||
  "name": "小米  手机",
 | 
			
		||||
  "keywords": "小米手机",
 | 
			
		||||
  "subTitle": "AI智慧全面屏 4GB +64GB 亮蓝色 全网通版 移动联通电信4G手机 双卡双待 双卡双待",
 | 
			
		||||
  "price": "2999",
 | 
			
		||||
  "promotionPrice": "1999",
 | 
			
		||||
  "originalPrice": "3999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":199,
 | 
			
		||||
  "putawayDate":"2021-04-03",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "2核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "蓝色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/4
 | 
			
		||||
{
 | 
			
		||||
  "id": "29",
 | 
			
		||||
  "name": "Apple iPhone 8 Plus 64GB 金色特别版 移动联通电信4G手机",
 | 
			
		||||
  "keywords": "苹果手机",
 | 
			
		||||
  "subTitle": "苹果手机 Apple产品年中狂欢节,好物尽享,美在智慧!速来 >> 勾选[保障服务][原厂保2年],获得AppleCare+全方位服务计划,原厂延保售后无忧。",
 | 
			
		||||
  "price": "5999",
 | 
			
		||||
  "promotionPrice": "4999",
 | 
			
		||||
  "originalPrice": "7999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5acc5248N6a5f81cd.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":1199,
 | 
			
		||||
  "putawayDate":"2021-04-04",
 | 
			
		||||
  "brandId": 51,
 | 
			
		||||
  "brandName": "苹果",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180607/timg.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "cpu",
 | 
			
		||||
      "attrValue": "4核"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "金色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/5
 | 
			
		||||
{
 | 
			
		||||
  "id": "30",
 | 
			
		||||
  "name": "HLA海澜之家简约动物印花短袖T恤",
 | 
			
		||||
  "keywords": "海澜之家衣服",
 | 
			
		||||
  "subTitle": "HLA海澜之家短袖T恤",
 | 
			
		||||
  "price": "199",
 | 
			
		||||
  "promotionPrice": "99",
 | 
			
		||||
  "originalPrice": "299",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5ad83a4fN6ff67ecd.jpg!cc_350x449.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":19,
 | 
			
		||||
  "putawayDate":"2021-04-05",
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "海澜之家",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "M"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "黑色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/6
 | 
			
		||||
{
 | 
			
		||||
  "id": "31",
 | 
			
		||||
  "name": "HLA海澜之家蓝灰花纹圆领针织布短袖T恤",
 | 
			
		||||
  "keywords": "海澜之家衣服",
 | 
			
		||||
  "subTitle": "HLA海澜之家短袖T恤",
 | 
			
		||||
  "price": "299",
 | 
			
		||||
  "promotionPrice": "199",
 | 
			
		||||
  "originalPrice": "299",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5ac98b64N70acd82f.jpg!cc_350x449.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":399,
 | 
			
		||||
  "putawayDate":"2021-04-06",
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "海澜之家",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "X"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "蓝灰"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/7
 | 
			
		||||
{
 | 
			
		||||
  "id": "32",
 | 
			
		||||
  "name": "HLA海澜之家短袖T恤男基础款",
 | 
			
		||||
  "keywords": "海澜之家衣服",
 | 
			
		||||
  "subTitle": "HLA海澜之家短袖T恤",
 | 
			
		||||
  "price": "269",
 | 
			
		||||
  "promotionPrice": "169",
 | 
			
		||||
  "originalPrice": "399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5a51eb88Na4797877.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":399,
 | 
			
		||||
  "putawayDate":"2021-04-07",
 | 
			
		||||
  "brandId": 50,
 | 
			
		||||
  "brandName": "海澜之家",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/99d3279f1029d32b929343b09d3c72de_222_222.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "L"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "蓝色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/8
 | 
			
		||||
{
 | 
			
		||||
  "id": "33",
 | 
			
		||||
  "name": "小米(MI)小米电视4A ",
 | 
			
		||||
  "keywords": "小米电视机家用电器",
 | 
			
		||||
  "subTitle": "小米(MI)小米电视4A 55英寸 L55M5-AZ/L55M5-AD 2GB+8GB HDR 4K超高清 人工智能网络液晶平板电视",
 | 
			
		||||
  "price": "2269",
 | 
			
		||||
  "promotionPrice": "2169",
 | 
			
		||||
  "originalPrice": "2399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b02804dN66004d73.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":132,
 | 
			
		||||
  "putawayDate":"2021-04-09",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 35,
 | 
			
		||||
  "categoryName": "手机数码",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "屏幕尺寸",
 | 
			
		||||
      "attrValue": "52"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "机身颜色",
 | 
			
		||||
      "attrValue": "黑色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/9
 | 
			
		||||
{
 | 
			
		||||
  "id": "34",
 | 
			
		||||
  "name": "小米(MI)小米电视4A 65英寸",
 | 
			
		||||
  "keywords": "小米电视机家用电器",
 | 
			
		||||
  "subTitle": "小米(MI)小米电视4A 65英寸 L55M5-AZ/L55M5-AD 2GB+8GB HDR 4K超高清 人工智能网络液晶平板电视",
 | 
			
		||||
  "price": "3269",
 | 
			
		||||
  "promotionPrice": "3169",
 | 
			
		||||
  "originalPrice": "3399",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b028530N51eee7d4.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":999,
 | 
			
		||||
  "putawayDate":"2021-04-10",
 | 
			
		||||
  "brandId": 6,
 | 
			
		||||
  "brandName": "小米",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/1e34aef2a409119018a4c6258e39ecfb_222_222.png",
 | 
			
		||||
  "categoryId": 35,
 | 
			
		||||
  "categoryName": "手机数码",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "屏幕尺寸",
 | 
			
		||||
      "attrValue": "65"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "机身颜色",
 | 
			
		||||
      "attrValue": "金色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/10
 | 
			
		||||
{
 | 
			
		||||
  "id": "35",
 | 
			
		||||
  "name": "耐克NIKE 男子 休闲鞋 ROSHE RUN 运动鞋 511881-010黑色41码",
 | 
			
		||||
  "keywords": "耐克运动鞋 鞋子",
 | 
			
		||||
  "subTitle": "耐克NIKE 男子 休闲鞋 ROSHE RUN 运动鞋 511881-010黑色41码",
 | 
			
		||||
  "price": "569",
 | 
			
		||||
  "promotionPrice": "369",
 | 
			
		||||
  "originalPrice": "899",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b235bb9Nf606460b.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":399,
 | 
			
		||||
  "putawayDate":"2021-04-11",
 | 
			
		||||
  "brandId": 58,
 | 
			
		||||
  "brandName": "NIKE",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/timg (51).jpg",
 | 
			
		||||
  "categoryId": 29,
 | 
			
		||||
  "categoryName": "男鞋",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺码",
 | 
			
		||||
      "attrValue": "42"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "黑色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/11
 | 
			
		||||
{
 | 
			
		||||
  "id": "36",
 | 
			
		||||
  "name": "耐克NIKE 男子 气垫 休闲鞋 AIR MAX 90 ESSENTIAL 运动鞋 AJ1285-101白色41码",
 | 
			
		||||
  "keywords": "耐克运动鞋 鞋子",
 | 
			
		||||
  "subTitle": "AIR MAX 90 ESSENTIAL 运动鞋 AJ1285-101白色",
 | 
			
		||||
  "price": "769",
 | 
			
		||||
  "promotionPrice": "469",
 | 
			
		||||
  "originalPrice": "999",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/5b19403eN9f0b3cb8.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":499,
 | 
			
		||||
  "putawayDate":"2021-04-13",
 | 
			
		||||
  "brandId": 58,
 | 
			
		||||
  "brandName": "NIKE",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/timg (51).jpg",
 | 
			
		||||
  "categoryId": 29,
 | 
			
		||||
  "categoryName": "男鞋",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺码",
 | 
			
		||||
      "attrValue": "44"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/12
 | 
			
		||||
{
 | 
			
		||||
  "id": "37",
 | 
			
		||||
  "name": "(华为)HUAWEI MateBook X Pro 2019款 13.9英寸3K触控全面屏 轻薄笔记本",
 | 
			
		||||
  "keywords": "轻薄笔记本华为 笔记本电脑",
 | 
			
		||||
  "subTitle": "轻薄华为笔记本 电脑",
 | 
			
		||||
  "price": "4769",
 | 
			
		||||
  "promotionPrice": "4469",
 | 
			
		||||
  "originalPrice": "4999",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200317/800_800_1555752016264mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":699,
 | 
			
		||||
  "putawayDate":"2021-04-14",
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "华为",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "16G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "4G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/13
 | 
			
		||||
{
 | 
			
		||||
  "id": "38",
 | 
			
		||||
  "name": "华为nova6se 手机 绮境森林 全网通(8G+128G)",
 | 
			
		||||
  "keywords": "轻薄笔记本华为 手机",
 | 
			
		||||
  "subTitle": "华为nova6se 手机",
 | 
			
		||||
  "price": "6769",
 | 
			
		||||
  "promotionPrice": "6469",
 | 
			
		||||
  "originalPrice": "6999",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/78_78_42B09549789695A42D621CF87DC53B5EBE9385772DC61FB9mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":899,
 | 
			
		||||
  "putawayDate":"2021-04-15",
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "华为",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "64G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "5G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/14
 | 
			
		||||
{
 | 
			
		||||
  "id": "39",
 | 
			
		||||
  "name": "iPhone7/6s/8钢化膜苹果8Plus全屏复盖抗蓝光防窥防偷看手机膜",
 | 
			
		||||
  "keywords": "手机膜",
 | 
			
		||||
  "subTitle": "iPhone7/6s/8钢化膜苹果8Plus全屏复盖抗蓝光防窥防偷看手机膜",
 | 
			
		||||
  "price": "29",
 | 
			
		||||
  "promotionPrice": "39",
 | 
			
		||||
  "originalPrice": "49",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/6df99dab78bb2014.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":799,
 | 
			
		||||
  "putawayDate":"2021-04-16",
 | 
			
		||||
  "brandId": 51,
 | 
			
		||||
  "brandName": "苹果",
 | 
			
		||||
  "brandImg": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/2b84746650fc122d67749a876c453619.png",
 | 
			
		||||
  "categoryId": 30,
 | 
			
		||||
  "categoryName": "手机配件",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "手机膜-材料",
 | 
			
		||||
      "attrValue": "钢化"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "手机膜-颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/15
 | 
			
		||||
{
 | 
			
		||||
  "id": "40",
 | 
			
		||||
  "name": "七匹狼短袖T恤男纯棉舒适春夏修身运动休闲短袖三条装 圆领3条装",
 | 
			
		||||
  "keywords": "七匹狼服装 衣服",
 | 
			
		||||
  "subTitle": "七匹狼短袖T恤男纯棉舒适春夏修身运动休闲短袖三条装 圆领3条装",
 | 
			
		||||
  "price": "129",
 | 
			
		||||
  "promotionPrice": "139",
 | 
			
		||||
  "originalPrice": "149",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/19e846e727dff337.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":199,
 | 
			
		||||
  "putawayDate":"2021-04-20",
 | 
			
		||||
  "brandId": 49,
 | 
			
		||||
  "brandName": "七匹狼",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/18d8bc3eb13533fab466d702a0d3fd1f40345bcd.jpg",
 | 
			
		||||
  "categoryId": 8,
 | 
			
		||||
  "categoryName": "T恤",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "尺寸",
 | 
			
		||||
      "attrValue": "M"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "颜色",
 | 
			
		||||
      "attrValue": "白色"
 | 
			
		||||
    },
 | 
			
		||||
     {
 | 
			
		||||
      "attrId": 3,
 | 
			
		||||
      "attrName": "适用季节",
 | 
			
		||||
      "attrValue": "春季"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/16
 | 
			
		||||
{
 | 
			
		||||
  "id": "41",
 | 
			
		||||
  "name": "华为P40 Pro手机",
 | 
			
		||||
  "keywords": "华为手机",
 | 
			
		||||
  "subTitle": "华为P40 Pro手机",
 | 
			
		||||
  "price": "2129",
 | 
			
		||||
  "promotionPrice": "2139",
 | 
			
		||||
  "originalPrice": "2149",
 | 
			
		||||
  "pic": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200327/1_DE7F785A7E0C276D3A1F40A5C6D82B07D2AED60CE1F73795mp.png",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":199,
 | 
			
		||||
  "putawayDate":"2021-05-03",
 | 
			
		||||
  "brandId": 3,
 | 
			
		||||
  "brandName": "华为",
 | 
			
		||||
  "brandImg": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20190129/17f2dd9756d9d333bee8e60ce8c03e4c_222_222.jpg",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "128G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "5G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
PUT /product_db/_doc/17
 | 
			
		||||
{
 | 
			
		||||
  "id": "42",
 | 
			
		||||
  "name": "朵唯智能手机 4G全网通 老人学生双卡双待手机",
 | 
			
		||||
  "keywords": "朵唯手机",
 | 
			
		||||
  "subTitle": "朵唯手机后置双摄,国产虎贲芯片!优化散热结构!浅薄机身!朵唯4月特惠!",
 | 
			
		||||
  "price": "3129",
 | 
			
		||||
  "promotionPrice": "3139",
 | 
			
		||||
  "originalPrice": "3249",
 | 
			
		||||
  "pic": "http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180615/xiaomi.jpg",
 | 
			
		||||
  "sale": 999,
 | 
			
		||||
  "hasStock": true,
 | 
			
		||||
  "salecount":1199,
 | 
			
		||||
  "putawayDate":"2021-06-01",
 | 
			
		||||
  "brandId": 59,
 | 
			
		||||
  "brandName": "朵唯",
 | 
			
		||||
  "brandImg": "http://tuling-mall.oss-cn-shenzhen.aliyuncs.com/tulingmall/images/20200311/2b84746650fc122d67749a876c453619.png",
 | 
			
		||||
  "categoryId": 19,
 | 
			
		||||
  "categoryName": "手机通讯",
 | 
			
		||||
  "attrs": [
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 1,
 | 
			
		||||
      "attrName": "容量",
 | 
			
		||||
      "attrValue": "32G"
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "attrId": 2,
 | 
			
		||||
      "attrName": "网络",
 | 
			
		||||
      "attrValue": "4G"
 | 
			
		||||
    }
 | 
			
		||||
  ]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								tulingmall-search/src/main/resources/rebel.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								tulingmall-search/src/main/resources/rebel.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
 | 
			
		||||
<!--
 | 
			
		||||
  This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
 | 
			
		||||
  Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
 | 
			
		||||
-->
 | 
			
		||||
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
 | 
			
		||||
 | 
			
		||||
	<id>tulingmall-search</id>
 | 
			
		||||
 | 
			
		||||
	<classpath>
 | 
			
		||||
		<dir name="D:/GitSource/tmallV5/tulingmall-search/target/classes">
 | 
			
		||||
		</dir>
 | 
			
		||||
	</classpath>
 | 
			
		||||
 | 
			
		||||
</application>
 | 
			
		||||
@@ -0,0 +1,40 @@
 | 
			
		||||
package com.tuling.tulingmall.search;
 | 
			
		||||
 | 
			
		||||
import com.tuling.tulingmall.search.dao.EsProductDao;
 | 
			
		||||
import com.tuling.tulingmall.search.domain.EsProduct;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.runner.RunWith;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
			
		||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
 | 
			
		||||
import org.springframework.test.context.junit4.SpringRunner;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@RunWith(SpringRunner.class)
 | 
			
		||||
@SpringBootTest
 | 
			
		||||
public class MallSearchApplicationTests {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EsProductDao productDao;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ElasticsearchTemplate elasticsearchTemplate;
 | 
			
		||||
    @Test
 | 
			
		||||
    public void contextLoads() {
 | 
			
		||||
    }
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testGetAllEsProductList(){
 | 
			
		||||
        List<EsProduct> esProductList = productDao.getAllEsProductList(null);
 | 
			
		||||
        System.out.print(esProductList);
 | 
			
		||||
    }
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testEsProductMapping(){
 | 
			
		||||
        elasticsearchTemplate.putMapping(EsProduct.class);
 | 
			
		||||
        Map mapping = elasticsearchTemplate.getMapping(EsProduct.class);
 | 
			
		||||
        System.out.println(mapping);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user