• springboot整合elasticsearch


    1、创建一个springboot工程并加入相关依赖

    pom.xml文件

    1. "1.0" encoding="UTF-8"?>
    2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    4. <modelVersion>4.0.0modelVersion>
    5. <parent>
    6. <groupId>org.springframework.bootgroupId>
    7. <artifactId>spring-boot-starter-parentartifactId>
    8. <version>2.3.12.RELEASEversion>
    9. <relativePath/>
    10. parent>
    11. <groupId>com.gjxgroupId>
    12. <artifactId>springboot-esartifactId>
    13. <version>0.0.1-SNAPSHOTversion>
    14. <name>springboot-esname>
    15. <description>springboot-esdescription>
    16. <properties>
    17. <java.version>1.8java.version>
    18. properties>
    19. <dependencies>
    20. <dependency>
    21. <groupId>com.alibabagroupId>
    22. <artifactId>fastjsonartifactId>
    23. <version>2.0.10version>
    24. dependency>
    25. <dependency>
    26. <groupId>org.springframework.bootgroupId>
    27. <artifactId>spring-boot-starter-data-elasticsearchartifactId>
    28. dependency>
    29. <dependency>
    30. <groupId>org.springframework.bootgroupId>
    31. <artifactId>spring-boot-starter-webartifactId>
    32. dependency>
    33. <dependency>
    34. <groupId>org.projectlombokgroupId>
    35. <artifactId>lombokartifactId>
    36. <optional>trueoptional>
    37. dependency>
    38. <dependency>
    39. <groupId>org.springframework.bootgroupId>
    40. <artifactId>spring-boot-starter-testartifactId>
    41. <scope>testscope>
    42. dependency>
    43. dependencies>
    44. <build>
    45. <plugins>
    46. <plugin>
    47. <groupId>org.springframework.bootgroupId>
    48. <artifactId>spring-boot-maven-pluginartifactId>
    49. <configuration>
    50. <excludes>
    51. <exclude>
    52. <groupId>org.projectlombokgroupId>
    53. <artifactId>lombokartifactId>
    54. exclude>
    55. excludes>
    56. configuration>
    57. plugin>
    58. plugins>
    59. build>
    60. project>

    2、创建一个配置类,获取ES工具类对象

    1. @Configuration
    2. public class EsConfig {
    3. @Bean
    4. public RestHighLevelClient restHighLevelClient(){
    5. RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
    6. RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
    7. );
    8. return restHighLevelClient;
    9. }
    10. }

    3、进行相关的ES操作

    3.1 对索引的相关操作

    3.1.1 创建索引

    1. @SpringBootTest
    2. class SpringbootEsApplicationTests {
    3. @Autowired
    4. private RestHighLevelClient client;
    5. /**
    6. * 添加索引
    7. * @throws Exception
    8. */
    9. @Test
    10. public void testCreateIndex() throws Exception{
    11. CreateIndexRequest createIndexRequest = new CreateIndexRequest("springboot-es01");
    12. CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
    13. System.out.println(createIndexResponse.isAcknowledged());
    14. }
    15. }

    3.1.2 删除索引

    1. @SpringBootTest
    2. class SpringbootEsApplicationTests {
    3. @Autowired
    4. private RestHighLevelClient client;
    5. /**
    6. * 删除索引
    7. * @throws Exception
    8. */
    9. @Test
    10. public void testDeleteIndex() throws Exception{
    11. DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest("springboot-es01");
    12. AcknowledgedResponse delete = client.indices().delete(deleteIndexRequest, RequestOptions.DEFAULT);
    13. System.out.println(delete.isAcknowledged());
    14. }
    15. }

    3.1.3 判断索引是否存在

    1. @SpringBootTest
    2. class SpringbootEsApplicationTests {
    3. @Autowired
    4. private RestHighLevelClient client;
    5. /**
    6. * 判断索引是否存在
    7. * @throws Exception
    8. */
    9. @Test
    10. public void testIndexExits() throws Exception{
    11. GetIndexRequest getIndexRequest = new GetIndexRequest("springboot-es01");
    12. boolean exists = client.indices().exists(getIndexRequest, RequestOptions.DEFAULT);
    13. System.out.println(exists);
    14. }
    15. }

    3.2 文档操作

    3.2.1 插入文档

    1. /**
    2. * 添加文档
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testInsertDoc() throws Exception{
    7. IndexRequest indexRequest = new IndexRequest("springboot-es01");
    8. //指定文档的id
    9. indexRequest.id("1");
    10. //指定文档的内容,XContentType xContentType 什么格式
    11. indexRequest.source(JSON.toJSONString(new User("dumpling",21,"新加坡")),XContentType.JSON);
    12. IndexResponse index = client.index(indexRequest, RequestOptions.DEFAULT);
    13. System.out.println(index.getResult());
    14. }

    3.2.2 获取文档

    1. /**
    2. * 获取文档
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testGetDoc() throws Exception{
    7. GetRequest getRequest = new GetRequest("springboot-es01");
    8. getRequest.id("1");
    9. GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT);
    10. String sourceAsString = getResponse.getSourceAsString();
    11. User user = JSON.parseObject(sourceAsString, User.class);
    12. System.out.println(user);
    13. }

    3.2.3 判断文档是否存在

    1. /**
    2. * 判断文档是否存在
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testDocExist() throws Exception{
    7. GetRequest getRequest = new GetRequest("springboot-es01");
    8. getRequest.id("1");
    9. boolean exists = client.exists(getRequest, RequestOptions.DEFAULT);
    10. System.out.println(exists);
    11. }

    3.2.4 删除文档

    1. /**
    2. * 删除文档
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testDeleteDoc() throws Exception{
    7. DeleteRequest deleteRequest = new DeleteRequest("springboot-es01");
    8. deleteRequest.id("1");
    9. DeleteResponse deleteResponse = client.delete(deleteRequest, RequestOptions.DEFAULT);
    10. System.out.println(deleteResponse.getResult());
    11. }

    3.2.5 更新文档

    1. /**
    2. * 更新文档
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testUpdateDoc() throws Exception{
    7. UpdateRequest updateRequest = new UpdateRequest("springboot-es01","1");
    8. User user = new User();
    9. user.setName("阿松大");
    10. updateRequest.doc(JSON.toJSONString(user),XContentType.JSON);
    11. UpdateResponse update = client.update(updateRequest, RequestOptions.DEFAULT);
    12. System.out.println(update.getResult());
    13. }

    3.2.6 批量添加文档

    1. /**
    2. * 批量添加文档
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testBuck() throws Exception{
    7. BulkRequest bulkRequest = new BulkRequest("springboot-es01");
    8. List list = new ArrayList<>();
    9. list.add(new User("2","张三1号",21,"北京"));
    10. list.add(new User("3","张三2号",21,"上海"));
    11. list.add(new User("4","张三3号",21,"深圳"));
    12. list.add(new User("5","张三4号",21,"广州"));
    13. list.stream().forEach(item->bulkRequest.add(new IndexRequest().id(item.getId()).source(JSON.toJSONString(item),XContentType.JSON)));
    14. BulkResponse bulk = client.bulk(bulkRequest, RequestOptions.DEFAULT);
    15. System.out.println(bulk.hasFailures());
    16. }

    3.2.7 复杂查询

    1. /**
    2. * 复杂查询
    3. * @throws Exception
    4. */
    5. @Test
    6. public void testSearch() throws Exception{
    7. //1.搜索请求对象
    8. SearchRequest searchRequest = new SearchRequest("springboot-es01");
    9. //2.创建条件对象
    10. SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    11. //搜索条件,匹配查询,范围查询,精准查询
    12. MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("name", "张");
    13. searchSourceBuilder.query(matchQueryBuilder);
    14. //分页
    15. searchSourceBuilder.from(0);
    16. searchSourceBuilder.size(2);
    17. //排序
    18. searchSourceBuilder.sort("age", SortOrder.ASC);
    19. //高亮
    20. HighlightBuilder highlightBuilder = new HighlightBuilder();
    21. highlightBuilder.field("name");
    22. highlightBuilder.preTags("");
    23. highlightBuilder.postTags("");
    24. searchSourceBuilder.highlighter(highlightBuilder);
    25. //3.把条件对象放入搜索请求对象中
    26. searchRequest.source(searchSourceBuilder);
    27. SearchResponse search = client.search(searchRequest, RequestOptions.DEFAULT);
    28. System.out.println("总条数:"+search.getHits().getTotalHits().value);
    29. SearchHit[] hits = search.getHits().getHits();
    30. //Arrays.stream(hits).forEach(item-> System.out.println(item.getSourceAsString()));
    31. Arrays.stream(hits).forEach(item-> System.out.println(item.getHighlightFields()));
    32. }

    4、京东搜索案例

    4.1 创建项目

    pom.xml

    1. <dependencies>
    2. <dependency>
    3. <groupId>org.jsoupgroupId>
    4. <artifactId>jsoupartifactId>
    5. <version>1.15.2version>
    6. dependency>
    7. <dependency>
    8. <groupId>com.alibabagroupId>
    9. <artifactId>fastjsonartifactId>
    10. <version>2.0.10version>
    11. dependency>
    12. <dependency>
    13. <groupId>org.springframework.bootgroupId>
    14. <artifactId>spring-boot-starter-data-elasticsearchartifactId>
    15. dependency>
    16. <dependency>
    17. <groupId>org.springframework.bootgroupId>
    18. <artifactId>spring-boot-starter-webartifactId>
    19. dependency>

    4.2 爬取京东商品工具类

    1. public class HtmlParseUtil {
    2. public static List ParseJd(String keyword) throws Exception {
    3. String path = "https://search.jd.com/Search?keyword="+keyword;
    4. //获取京东搜索的整个网页对象
    5. Document document = Jsoup.parse(new URL(path), 30000);
    6. //System.out.println(document);
    7. Element j_goodsList = document.getElementById("J_goodsList");
    8. //System.out.println(j_goodsList);
    9. Elements li = j_goodsList.getElementsByTag("li");
    10. //System.out.println(li);
    11. List list = new ArrayList<>();
    12. for (Element e : li){
    13. String pPrice = e.getElementsByClass("p-price").text();
    14. String pName = e.getElementsByClass("p-name").text();
    15. String pImg = e.getElementsByTag("img").attr("data-lazy-img");
    16. //System.out.println(pImg);
    17. list.add(new Product(pName,pImg,pPrice));
    18. }
    19. //System.out.println(list);
    20. return list;
    21. }
    22. }

    4.3 ES配置类

    如果不写这个配置类的话,默认连接的是本地的elasticsearch

    1. @Configuration
    2. public class EsConfig {
    3. @Bean
    4. public RestHighLevelClient restHighLevelClient(){
    5. RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
    6. RestClient.builder(new HttpHost("127.0.0.1",9200,"http"))
    7. );
    8. return restHighLevelClient;
    9. }
    10. }

    4.4 导入数据

    4.4.1 cotroller层

    1. @RestController
    2. @RequestMapping("product")
    3. @CrossOrigin
    4. public class ProductController {
    5. @Autowired
    6. private ProductService productService;
    7. @GetMapping("export/{keyword}")
    8. public CommonResult export(@PathVariable String keyword) throws Exception {
    9. return productService.export(keyword);
    10. }
    11. }

    4.4.2 service层

    1. @Service
    2. public class ProductService {
    3. @Autowired
    4. private RestHighLevelClient client;
    5. public CommonResult export(String keyword) throws Exception{
    6. List products = HtmlParseUtil.ParseJd(keyword);
    7. //1、创建索引
    8. GetIndexRequest getIndexRequest = new GetIndexRequest("jd_product");
    9. boolean exists = client.indices().exists(getIndexRequest,RequestOptions.DEFAULT);
    10. if (!exists){
    11. CreateIndexRequest createIndexRequest = new CreateIndexRequest("jd_product");
    12. CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
    13. System.out.println("是否创建索引:"+createIndexResponse.isAcknowledged());
    14. }
    15. BulkRequest bulkRequest = new BulkRequest("jd_product");
    16. products.stream().forEach(item-> bulkRequest.add(new IndexRequest().source(JSON.toJSONString(item), XContentType.JSON)));
    17. BulkResponse bulk = client.bulk(bulkRequest, RequestOptions.DEFAULT);
    18. System.out.println(bulk.hasFailures());
    19. if (!bulk.hasFailures()){
    20. return new CommonResult(2000,"添加成功",null);
    21. }
    22. return new CommonResult(5000,"添加失败",null);
    23. }
    24. }

    4.5 查询数据

    4.5.1 controller层

    1. @RestController
    2. @RequestMapping("product")
    3. @CrossOrigin
    4. public class ProductController {
    5. @Autowired
    6. private ProductService productService;
    7. @GetMapping("search/{keyword}")
    8. public CommonResult search(@PathVariable String keyword,Integer pageSize,Integer currentPage) throws Exception {
    9. return productService.search(keyword,pageSize,currentPage);
    10. }
    11. }

    4.5.2 service层

    1. @Service
    2. public class ProductService {
    3. @Autowired
    4. private RestHighLevelClient client;
    5. public CommonResult search(String keyword,Integer pageSize,Integer currentPage) throws IOException {
    6. SearchRequest searchRequest = new SearchRequest("jd_product");
    7. SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    8. MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("name",keyword);
    9. searchSourceBuilder.query(matchQueryBuilder);
    10. //设置分页
    11. searchSourceBuilder.from((currentPage-1)*pageSize);
    12. searchSourceBuilder.size(pageSize);
    13. //设置高亮
    14. HighlightBuilder highlightBuilder = new HighlightBuilder();
    15. highlightBuilder.field("name");
    16. highlightBuilder.preTags("");
    17. highlightBuilder.postTags("");
    18. searchSourceBuilder.highlighter(highlightBuilder);
    19. searchRequest.source(searchSourceBuilder);
    20. SearchResponse search = client.search(searchRequest, RequestOptions.DEFAULT);
    21. //获取查询结果
    22. SearchHit[] hits = search.getHits().getHits();
    23. ArrayList> list = new ArrayList<>();
    24. for (SearchHit hit:hits){
    25. Map map = hit.getSourceAsMap();
    26. //获取高亮显示的name
    27. HighlightField name = hit.getHighlightFields().get("name");
    28. Text[] fragments = name.fragments();
    29. for (Text text :fragments){
    30. //替换map中的name
    31. map.put("name",text.toString());
    32. }
    33. list.add(map);
    34. }
    35. //获取数据总条数
    36. long value = search.getHits().getTotalHits().value;
    37. Map result = new HashMap<>();
    38. result.put("total",value);
    39. result.put("list",list);
    40. if (list.size()>0){
    41. return new CommonResult(2000,"搜索成功",result);
    42. }else {
    43. return new CommonResult(5000,"搜索失败",result);
    44. }
    45. }
    46. }

    4.5.3 前端vue页面

    1. <template>
    2. <div class="page">
    3. <div id="app" class=" mallist tmall- page-not-market ">
    4. <div id="header" class=" header-list-app">
    5. <div class="headerLayout">
    6. <div class="headerCon ">
    7. <h1 id="mallLogo" style="padding: 10px">
    8. <img src="../assets/jdlogo.png" alt="" height="60">
    9. h1>
    10. <div class="header-extra">
    11. <div id="mallSearch" class="mall-search">
    12. <form name="searchTop" class="mallSearch-form clearfix">
    13. <fieldset>
    14. <div class="mallSearch-input clearfix">
    15. <div class="s-combobox" id="s-combobox-685">
    16. <div class="s-combobox-input-wrap">
    17. <input v-model="keyword" type="text" autocomplete="off" id="mq"
    18. class="s-combobox-input" aria-haspopup="true" style="width: 450px">
    19. div>
    20. div>
    21. <button type="submit" @click="searchKey" id="searchbtn">搜索button>
    22. div>
    23. fieldset>
    24. form>
    25. <ul class="relKeyTop">
    26. <li><a>老闫说Javaa>li>
    27. <li><a>老闫说前端a>li>
    28. <li><a>老闫说Linuxa>li>
    29. <li><a>老闫说大数据a>li>
    30. <li><a>老闫聊理财a>li>
    31. ul>
    32. div>
    33. div>
    34. div>
    35. div>
    36. div>
    37. <div id="content">
    38. <div class="main">
    39. <form class="navAttrsForm">
    40. <div class="attrs j_NavAttrs" style="display:block">
    41. <div class="brandAttr j_nav_brand">
    42. <div class="j_Brand attr">
    43. <div class="attrKey">
    44. 品牌
    45. div>
    46. <div class="attrValues">
    47. <ul class="av-collapse row-2">
    48. <li><a href="#"> 老闫说 a>li>
    49. <li><a href="#"> Java a>li>
    50. ul>
    51. div>
    52. div>
    53. div>
    54. div>
    55. form>
    56. <div class="filter clearfix">
    57. <a class="fSort fSort-cur">综合<i class="f-ico-arrow-d">i>a>
    58. <a class="fSort">人气<i class="f-ico-arrow-d">i>a>
    59. <a class="fSort">新品<i class="f-ico-arrow-d">i>a>
    60. <a class="fSort">销量<i class="f-ico-arrow-d">i>a>
    61. <a class="fSort">价格<i class="f-ico-triangle-mt">i><i class="f-ico-triangle-mb">i>a>
    62. div>
    63. <div class="view grid-nosku" >
    64. <div class="product" v-for="item in results">
    65. <div class="product-iWrap">
    66. <div class="productImg-wrap">
    67. <a class="productImg">
    68. <img :src="item.img">
    69. a>
    70. div>
    71. <p class="productPrice">
    72. <em>{{item.price}}em>
    73. p>
    74. <p class="productTitle">
    75. <a v-html="item.name"> a>
    76. p>
    77. <div class="productShop">
    78. <span>店铺: 老闫说Java span>
    79. div>
    80. <p class="productStatus">
    81. <span>月成交<em>999笔em>span>
    82. <span>评价 <a>3a>span>
    83. p>
    84. div>
    85. div>
    86. div>
    87. <el-pagination
    88. @size-change="handleSizeChange"
    89. @current-change="handleCurrentChange"
    90. :current-page=currentPage
    91. :page-sizes=pageSizes
    92. :page-size=pageSize
    93. layout="total, sizes, prev, pager, next, jumper"
    94. :total=total>
    95. el-pagination>
    96. div>
    97. div>
    98. div>
    99. div>
    100. template>
    101. <script>
    102. export default {
    103. name: "jd",
    104. data(){
    105. return {
    106. keyword: '', // 搜索的关键字
    107. results:[], // 后端返回的结果
    108. currentPage:1,
    109. pageSizes:[5,10,15,20],
    110. pageSize:5,
    111. total:0,
    112. }
    113. },
    114. methods:{
    115. searchKey(){
    116. console.log("123");
    117. this.$http.get('http://localhost:8080/product/search/'+this.keyword+"?pageSize="+this.pageSize+"¤tPage="+this.currentPage).then(response=>{
    118. console.log(response.data.data);
    119. this.results=response.data.data.list;
    120. this.total=response.data.data.total;
    121. })
    122. },
    123. handleSizeChange(val) {
    124. this.pageSize=val;
    125. this.searchKey();
    126. },
    127. handleCurrentChange(val) {
    128. this.currentPage=val;
    129. this.searchKey();
    130. }
    131. }
    132. }
    133. script>
    134. <style>
    135. /*** uncss> filename: http://localhost:9090/css/global.css ***/
    136. body,button,fieldset,form,h1,input,legend,li,p,ul{margin:0;padding:0}body,button,input{font:12px/1.5 tahoma,arial,"\5b8b\4f53";-ms-overflow-style:scrollbar}button,h1,input{font-size:100%}em{font-style:normal}ul{list-style:none}a{text-decoration:none}a:hover{text-decoration:underline}legend{color:#000}fieldset,img{border:0}#content,#header{margin-left:auto;margin-right:auto}
    137. html{zoom:expression(function(ele){ ele.style.zoom = "1"; document.execCommand("BackgroundImageCache", false, true); }(this))}
    138. @font-face{font-family:mui-global-iconfont;src:url(//at.alicdn.com/t/font_1401963178_8135476.eot);src:url(//at.alicdn.com/t/font_1401963178_8135476.eot?#iefix) format('embedded-opentype'),url(//at.alicdn.com/t/font_1401963178_8135476.woff) format('woff'),url(//at.alicdn.com/t/font_1401963178_8135476.ttf) format('truetype'),url(//at.alicdn.com/t/font_1401963178_8135476.svg#iconfont) format('svg')}#mallPage{width:auto;min-width:990px;background-color:transparent}#content{width:990px;margin:auto}#mallLogo{float:left;z-index:9;padding-top:28px;width:280px;height:64px;line-height:64px;position:relative}.page-not-market #mallLogo{width:400px}.clearfix:after,.clearfix:before,.headerCon:after,.headerCon:before{display:table;content:"";overflow:hidden}#mallSearch legend{display:none}.clearfix:after,.headerCon:after{clear:both}.clearfix,.headerCon{zoom:1}#mallPage #header{margin-top:-30px;width:auto;margin-bottom:0;min-width:990px;background:#fff}#header{height:122px;margin-top:-26px!important;background:#fff;min-width:990px;width:auto!important;position:relative;z-index:1000}#mallSearch #mq,#mallSearch fieldset,.mallSearch-input{position:relative}.headerLayout{width:990px;padding-top:26px;margin:0 auto}.header-extra{overflow:hidden}#mallSearch{float:right;padding-top:25px;width:390px;overflow:hidden}.mallSearch-form{border:solid #FF0036;border-width:3px 0 3px 3px}.mallSearch-input{background:#fff;height:30px}#mallSearch #mq{color:#000;margin:0;z-index:2;width:289px;height:20px;line-height:20px;padding:5px 3px 5px 5px;outline:0;border:none;font-weight:900;background:url(data:image/gif;base64,R0lGODlhAQADAJEAAObm5t3d3ff39wAAACH5BAAAAAAALAAAAAABAAMAAAICDFQAOw==) repeat-x;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}#mallSearch button{position:absolute;right:0;top:0;width:90px;border:0;font-size:16px;letter-spacing:4px;cursor:pointer;color:#fff;background-color:#FF0036;height:30px;overflow:hidden;font-family:'\5FAE\8F6F\96C5\9ED1',arial,"\5b8b\4f53"}#mallSearch .s-combobox{height:30px}#mallSearch .s-combobox .s-combobox-input:focus{outline:0}button::-moz-focus-inner{border:0;padding:0;margin:0}.page-not-market #mallSearch{width:540px!important}.page-not-market #mq{width:439px!important}
    139. /*** uncss> filename: http://localhost:9090/css/test.css ***/
    140. #mallSearch{float:none}
    141. .page-not-market #mallLogo{width:280px}
    142. .header-list-app #mallSearch{width:448px}
    143. .header-list-app #mq{width:400px!important} @media (min-width:1210px){#header .headerCon,#header .headerLayout,.main{width:1190px!important}
    144. .header-list-app #mallSearch{width:597px!important}
    145. .header-list-app #mq{width:496px}}@media (min-width:600px) and (max-width:800px) and (orientation:portrait){.pg .page{min-width:inherit}.pg #mallPage,.pg #mallPage #header{min-width:740px}.pg #header .headerCon,.pg #header .headerLayout,.pg .main{width:740px!important}.pg #mallPage #mallLogo{width:260px}.pg #header{min-width:inherit}.pg #mallSearch .mallSearch-input{padding-right:95px}.pg #mallSearch .s-combobox{width:100%!important}.pg #mallPage .header-list-app #mallSearch{width:auto!important}.pg #mallPage .header-list-app #mallSearch #mq{width:100%!important;padding:5px 0 5px 5px}}i{font-style:normal}.main,.page{position:relative}.page{overflow:hidden}@font-face{font-family:tm-list-font;src:url(//at.alicdn.com/t/font_1442456441_338337.eot);src:url(//at.alicdn.com/t/font_1442456441_338337.eot?#iefix) format('embedded-opentype'),url(//at.alicdn.com/t/font_1442456441_338337.woff) format('woff'),url(//at.alicdn.com/t/font_1442456441_338337.ttf) format('truetype'),url(//at.alicdn.com/t/font_1442456441_338337.svg#iconfont) format('svg')}::selection{background:rgba(0,0,0,.1)}*{-webkit-tap-highlight-color:rgba(0,0,0,.3)}b{font-weight:400}.page{background:#fff;min-width:990px}#content{margin:0!important;width:100%!important}.main{margin:auto;width:990px}.main img{-ms-interpolation-mode:bicubic}.fSort i{background:url(//img.alicdn.com/tfs/TB1XClLeAY2gK0jSZFgXXc5OFXa-165-206.png) 9999px 9999px no-repeat}#mallSearch .s-combobox{width:auto}::-ms-clear,::-ms-reveal{display:none}.attrKey{white-space:nowrap;text-overflow:ellipsis}.attrs{border-top:1px solid #E6E2E1}.attrs a{outline:0}.attr{background-color:#F7F5F5;border-color:#E6E2E1 #E6E2E1 #D1CCC7;border-style:solid solid dotted;border-width:0 1px 1px}.attr ul:after,.attr:after{display:block;clear:both;height:0;content:' '}.attrKey{float:left;padding:7px 0 0;width:10%;color:#B0A59F;text-indent:13px}.attrKey{display:block;height:16px;line-height:16px;overflow:hidden}.attrValues{position:relative;float:left;background-color:#FFF;width:90%;padding:4px 0 0;overflow:hidden}.attrValues ul{position:relative;margin-right:105px;margin-left:25px}.attrValues ul.av-collapse{overflow:hidden}.attrValues li{float:left;height:22px;line-height:22px}.attrValues li a{position:relative;color:#806F66;display:inline-block;padding:1px 20px 1px 4px;line-height:20px;height:20px;white-space:nowrap}.attrValues li a:hover{color:#ff0036;text-decoration:none}.brandAttr .attr{border:2px solid #D1CCC7;margin-top:-1px}.brandAttr .attrKey{padding-top:9px}.brandAttr .attrValues{padding-top:6px}.brandAttr .av-collapse{overflow:hidden;max-height:60px}.brandAttr li{margin:0 8px 8px 0}.brandAttr li a{text-overflow:ellipsis;overflow:hidden}.navAttrsForm{position:relative}.relKeyTop{padding:4px 0 0;margin-left:-13px;height:16px;overflow:hidden;width:100%}.relKeyTop li{display:inline-block;border-left:1px solid #ccc;line-height:1.1;padding:0 12px}.relKeyTop li a{color:#999}.relKeyTop li a:hover{color:#ff0036;text-decoration:none}.filter i{display:inline-block;overflow:hidden}.filter{margin:10px 0;padding:5px;position:relative;z-index:10;background:#faf9f9;color:#806f66}.filter i{position:absolute}.filter a{color:#806f66;cursor:pointer}.filter a:hover{color:#ff0036;text-decoration:none}.fSort{float:left;height:22px;line-height:20px;line-height:24px\9;border:1px solid #ccc;background-color:#fff;z-index:10}.fSort{position:relative}.fSort{display:inline-block;margin-left:-1px;overflow:hidden;padding:0 15px 0 5px}.fSort:hover,a.fSort-cur{color:#ff0036;background:#F1EDEC}.fSort i{top:6px;right:5px;width:7px;height:10px;line-height:10px}.fSort .f-ico-arrow-d{background-position:-22px -23px}.fSort-cur .f-ico-arrow-d,.fSort:hover .f-ico-arrow-d{background-position:-30px -23px}i.f-ico-triangle-mb,i.f-ico-triangle-mt{border:4px solid transparent;height:0;width:0}i.f-ico-triangle-mt{border-bottom:4px solid #806F66;top:2px}i.f-ico-triangle-mb{border-top:4px solid #806F66;border-width:3px\9;right:6px\9;top:12px}:root i.f-ico-triangle-mb{border-width:4px\9;right:5px\9}i.f-ico-triangle-mb,i.f-ico-triangle-mt{border:4px solid transparent;height:0;width:0}i.f-ico-triangle-mt{border-bottom:4px solid #806F66;top:2px}i.f-ico-triangle-mb{border-top:4px solid #806F66;border-width:3px\9;right:6px\9;top:12px}:root i.f-ico-triangle-mb{border-width:4px\9;right:5px\9}.view:after{clear:both;content:' '}.productImg,.productPrice em b{vertical-align:middle}.product{position:relative;float:left;padding:0;margin:0 0 20px;line-height:1.5;overflow:visible;z-index:1}.product:hover{overflow:visible;z-index:3;background:#fff}.product-iWrap{position:absolute;background-color:#fff;margin:0;padding:4px 4px 0;font-size:0;border:1px solid #f5f5f5;border-radius:3px}.product-iWrap *{font-size:12px}.product:hover .product-iWrap{height:auto;margin:-3px;border:4px solid #ff0036;border-radius:0;-webkit-transition:border-color .2s ease-in;-moz-transition:border-color .2s ease-in;-ms-transition:border-color .2s ease-in;-o-transition:border-color .2s ease-in;transition:border-color .2s ease-in}.productPrice,.productShop,.productStatus,.productTitle{display:block;overflow:hidden;margin-bottom:3px}.view:after{display:block}.view{margin-top:10px}.view:after{height:0}.productImg-wrap{display:table;table-layout:fixed;height:210px;width:100%;padding:0;margin:0 0 5px}.productImg-wrap a,.productImg-wrap img{max-width:100%;max-height:210px}.productImg{display:table-cell;width:100%;text-align:center}.productImg img{display:block;margin:0 auto}.productPrice{font-family:arial,verdana,sans-serif!important;color:#ff0036;font-size:14px;height:30px;line-height:30px;margin:0 0 5px;letter-spacing:normal;overflow:inherit!important;white-space:nowrap}.productPrice *{height:30px}.productPrice em{float:left;font-family:arial;font-weight:400;font-size:20px;color:#ff0036}.productPrice em b{margin-right:2px;font-weight:700;font-size:14px}.productTitle{display:block;color:#666;height:14px;line-height:12px;margin-bottom:3px;word-break:break-all;font-size:0;position:relative}.productTitle *{font-size:12px;font-family:\5FAE\8F6F\96C5\9ED1;line-height:14px}.productTitle a{color:#333}.productTitle a:hover{color:#ff0036!important}.productTitle a:visited{color:#551A8B!important}.product:hover .productTitle{height:14px}.productShop{position:relative;height:22px;line-height:20px;margin-bottom:5px;color:#999;white-space:nowrap;overflow:visible}.productStatus{position:relative;height:32px;border:none;border-top:1px solid #eee;margin-bottom:0;color:#999}.productStatus span{float:left;display:inline-block;border-right:1px solid #eee;width:39%;padding:10px 1px;margin-right:6px;line-height:12px;text-align:left;white-space:nowrap}.productStatus a,.productStatus em{margin-top:-8px;font-family:arial;font-size:12px;font-weight:700}.productStatus em{color:#b57c5b}.productStatus a{color:#38b}.productImg-wrap{position:relative}.product-iWrap{min-height:98%;width:210px}.view{padding-left:5px;padding-right:5px}.view{width:1023px}.view .product{width:220px;margin-right:33px}@media (min-width:1210px){.view{width:1210px;padding-left:5px;padding-right:5px}.view .product{width:220px;margin-right:20px}}@media (min-width:600px) and (max-width:800px) and (orientation:portrait){.view{width:775px;padding-left:5px;padding-right:5px}.view .product{width:220px;margin-right:35px}}.product{height:372px}.grid-nosku .product{height:333px}
    146. style>
  • 相关阅读:
    MySQL8 Group By 新特性
    僵尸进程的产生与处理
    开店星小程序上架教程和后台Request failed with status code 500[undefined]问题处理
    Docker部署Elasticsearch和Head
    21天学习挑战:经典算法---希尔排序
    【心理学·人物】第二期(学术X综艺)
    Python爬虫——Selenium 浏览器交互与异常处理
    MemArts :高效解决存算分离架构中数据访问的组件
    vue实现一个鼠标滑动预览视频封面组件
    Scrapy知识系列:使用CrawlerProcess从外部运行多个spider时,运行脚本需要与scrapy.cfg在同级目录
  • 原文地址:https://blog.csdn.net/Dumpling_skin/article/details/126359507