11.elasticsearch实现前端页面基本搜索

本文介绍了如何将数据导入Elasticsearch实现前端页面的基本搜索功能。数据导入涉及搜索字段、聚合字段和展示数据的处理。使用Feign进行微服务间的远程调用,将SPU转换为Goods对象并存储到Elasticsearch,同时展示了构建Elasticsearch查询条件的方法。
摘要由CSDN通过智能技术生成

一、数据导入elasticsearch中

  1. 问题:把哪些数据导入到elasticsearch中?

主要都是一些搜索字段和聚合字段,和展示在页面的数据;搜索字段和聚合字段要单独拎出来,不能放在String spu或sku中,因为要作为字段搜索和聚合。展示数据放在一个String skus中,到时候在提取数据渲染。

1.把可能作为搜索数据专门全部放在一个String类型里,分词,包括标题,分类,品牌的数据,全部在一起,并且分词(type = FieldType.Text)
@Field(type = FieldType.Text, analyzer = “ik_max_word”)
private String all;

2.sku里面有很多要展示在页面的数据,放在String里,不必分词(type = FieldType.Keyword)
@Field(type = FieldType.Keyword, index = false)
private String skus;// List信息的json结构

3.Long brandId,Long cid1,Long cid2,Long cid3,List price,createTime,Map<String, Object> specs

@Document(indexName = "goods", type = "docs", shards = 1, replicas = 0)
public class Goods {
   
    @Id
    private Long id; // spuId
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String all; // 所有需要被搜索的信息,包含标题,分类,甚至品牌
    @Field(type = FieldType.Keyword, index = false)
    private String subTitle;// 卖点
    private Long brandId;// 品牌id
    private Long cid1;// 1级分类id
    private Long cid2;// 2级分类id
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值