启动时候创建的 索引mapping
和save时候 创建的 索引mapping
之间的区别测试。
实体类
/**
* @author river
* @date 2019/2/27 14:47
**/
@Data
@Document(indexName = "student-" + "#{ T(com.river.es.entity.Student).dateStr() }",
type = "student",
shards = 2,
replicas = 1, refreshInterval = "-1")
public class Student {
@Id
private String id;
@Field(type = FieldType.Keyword)
private String name;
@Field(type = FieldType.Integer)
private Integer age;
private String desc;
public static String dateStr()
{
return DateUtil.now().replace(" ","");
}
}
springboot 启动后创建的mapping为
{
"student-2019-05-3109:18:49": {
"mappings": {
"student": {
"properties": {
"age": {
"type": "integer"
},
"name": {
"type": "keyword"
}
}
}
}
}
}
save时候发现没有 自己(es)默认创建的
"student-2019-05-3109:25:17": {
"mappings": {
"student": {
"properties": {
"age": {
"type": "long"
},
"desc": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
不一样,这个问题 可能导致,下次启动失败。因为es不支持 修改 mapping
网友评论