date 、float、long都是不能够被拆分的
@Field(type=FieldType.Text, analyzer="ik_max_word") 表示该字段是一个文本,并作最大程度拆分,默认建立索引
@Field(type=FieldType.Text,index=false) 表示该字段是一个文本,不建立索引
@Field(type=FieldType.Date) 表示该字段是一个文本,日期类型,默认不建立索引
@Field(type=FieldType.Long) 表示该字段是一个长整型,默认建立索引
@Field(type=FieldType.Keyword) 表示该字段内容是一个文本并作为一个整体不可分,默认建立索引
@Field(type=FieldType.Float) 表示该字段内容是一个浮点类型并作为一个整体不可分,默认建立索引
类实例展示代码
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Data
@Document(indexName = "product", shards = 3, replicas = 2) //shards:分片数量,replicas:副本数量
public class Product {
@Id
private Long id;
@Field(type = FieldType.Text, analyzer = "ik_max_word")
private String title;
@Field(type = FieldType.Keyword, index = false)
private String images;
@Field(type = FieldType.Double)
private Double price;
@Field(type = FieldType.Keyword)
private String brand;
@Field(type = FieldType.Keyword)
private String category;
}