一、数据导入elasticsearch中
- 问题:把哪些数据导入到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