# 错误整理
- java.lang.IllegalStateException: Received message from unsupported version: [6.4.3] minimal compatible version is: [6.8.0]
大概率版本不匹配问题
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.1.2.RELEASE</version>
2
此对应的elasticSearch版本为6.4.3
所以针对boot版本,要下载相对应的elasticSearch版本
failed to get node info for {#transport#-1}{P4kDZVTTSJW9w7G30pMOrw}{127.0.0.1}{127.0.0.1:9300
此原因也可能是上述的版本不匹配的原因导致No Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator
因为写了一个含部分属性的构造函数导致的,删除此构造函数即可解决问题
或者再写一个无参构造函数
public GoodsInfoBo(){}
public GoodsInfoBo(String id, String name, BigDecimal price) {
this.id = id;
this.name = name;
this.price = price;
}
2
3
4
5
6
7
- required a bean named 'elasticsearchTemplate' that could not be found.
可能缺少配置
#es地址
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
2
# springboot项目正常启动但接口404
原因一:启动类中存在注解@ComponentScan,扫描public interface GoodsRepository extends ElasticsearchRepository<GoodsInfoBo, String>,此类最好添加注解@Repository
- Can't merge a non object mapping [createTime] with an object mapping [createTime]
- 原因:这个错误消息意味着您正在尝试更改一个现有的映射。然而,这在Elasticsearch中是不可能的。一旦创建了映射,就不能更改它。只能再新增字段或者删除当前索引并重新创建它
# 日期存储问题
因版本不同而异,3.1.X(含)前,默认采用jackson序列化java对象
- None of the configured nodes are available
- org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
- 原因:spring data elasticSearch 的版本与Spring boot、Elasticsearch版本不匹配
# 分页信息
Result window is too large, from + size must be less than or equal to: [10000] but was [999999]
# 聚合出错
聚合
聚合这些操作用单独的数据结构(fielddata)缓存到内存里了,需要单独开启
Fielddata is disabled on text fields by default. Set fielddata=true on [type] in order to load fielddata in memory by uninverting the inverted index.
默认 Elasticsearch 对 text 类型的字段是不可聚合的,基本类型可聚合
text(字符串类型默认是Field.text) fields are searchable by default, but by default are not available for aggregations, sorting, or scripting. If you try to sort, aggregate, or access values from a script on a text field, you will see this exception:
文本字段默认情况下是可搜索的,但默认情况下
不可用于聚合,排序或脚本编写。如果您尝试对文本字段中的脚本进行排序,聚合或访问值,则会看到此异常:
Fielddata is disabled on text fields by default. Set fielddata=true on your_field_name in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.
默认情况下,在文本字段上禁用字段数据。在your_field_name上设置fielddata = true,以通过反转取反的索引将字段数据加载到内存中。请注意,这可能会占用大量内存。
Field data is the only way to access the analyzed tokens from a full text field in aggregations, sorting, or scripting. For example, a full text field like New York would get analyzed as new and york. To aggregate on these tokens requires field data.
字段数据是在聚合,排序或脚本编制中从全文字段访问分析的令牌的唯一方法。例如,像纽约这样的全文字段将被分析为纽约和纽约。要汇总这些令牌,需要字段数据。
It usually doesn’t make sense to enable fielddata on text fields. Field data is stored in the heap with the field data cache because it is expensive to calculate. Calculating the field data can cause latency spikes, and increasing heap usage is a cause of cluster performance issues.
在文本字段上启用字段数据通常没有任何意义。字段数据与字段数据缓存一起存储在堆中,因为计算起来很昂贵。计算字段数据可能会导致延迟尖峰,并且增加堆使用率是导致群集性能问题的原因。
Most users who want to do more with text fields use multi-field mappings by having both a text field for full text searches, and an unanalyzed keyword field for aggregations, as follows:
想要对文本字段进行更多处理的大多数用户使用多字段映射,方法是同时具有用于全文搜索的文本字段和用于聚合的未分析关键字字段,如下所示:
PUT my-index-000001
{
"mappings": {
"properties": {
"my_field": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- Use the my_field field for searches.
- Use the my_field.keyword field for aggregations, sorting, or in scripts.