赞
踩
本文主要介绍在Elasticsearch中实现商品搜索功能
- get hanzo/_analyze
- {
-
- "text": "小米手机",
- "tokenizer": "standard"
- }
- get hanzo/_analyze
- {
-
- "text": "小米手机",
- "tokenizer": "ik_max_word"
- }
在商品信息实体类中用@Document、@Field等注解。对于需要中文分词的字段,我们直接使用@Field注解属性设置为ik_max_word。
- /**
- * @Author 皓宇QAQ
- * @Date 2020/6/4 20:49
- * @Description:搜索中的商品信息
- */
- @Document(indexName = "hanzo", type = "product",shards = 1,replicas = 0)
- @Data
- public class EsProduct implements Serializable {
-
- private static final long serialVersionUID = -1L;
- @Id
- private Long goodsId;
- @Field(analyzer = "ik_max_word",type = FieldType.Text)
- private String goodsName;
- @Field(analyzer = "ik_max_word",type = FieldType.Text)
- private String goodsIntro;
-
- private Long goodsCategoryId;
-
- private String goodsCoverImg;
-
- private String goodsCarousel;
-
- private Integer originalPrice;
-
- private Integer sellingPrice;
-
- private Integer stockNum;
-
- private String tag;
-
- private Byte goodsSellStatus;
-
- private Integer createUser;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
- private Date createTime;
-
- private Integer updateUser;
-
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone =
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。