首先呢,我设置了一个model
@Data
@Document(indexName = "myes2", type = "tt")
public class MyEs2 implements Serializable {
@Id
@Field(type = FieldType.Long, store = true, index = false)
private Long id;
@Field(type = FieldType.Text, store = true, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
private String title;
@Field(type = FieldType.Text, store = true, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
private String content;
}
可以看到ID我设置的是long类型,但是呢生成的mapping就变成了keyword
{
"myes2": {
"mappings": {
"tt": {
"properties": {
"content": {
"type": "text",
"store": true,
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"id": {
"type": "keyword"
},
"title": {
"type": "text",
"store": true,
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
}
}
}
}
}
}
如果我强制把这个改成LONG,执行保存的时候,就会抛异常
这是为什么呀,感觉好烦呀,虽然不影响我用,我也不会把ID设置成LONG,但是我搜遍了全网也没有找到有这类的问题,如果是官方就这么设计的,希望大家告诉我一下,顺便告诉我在哪看到的这么设计的,我的环境是
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
jdk是1.8
elasticsearch是6.2.4版本,我的强迫症都快犯了