ElasticSearch使用注意

1、代码中配置cluster-name和es中的cluster-name要统一,然后es中network-port要正确127.0.0.1。

2、springboot中与es的版本要统一,在spring-data-elasticsearch中子包transport-netty4-client可以查找到。

不统一可能遇见报错:无法连接到es、

3、尽量不要用最新版,最新稳定版也不要用,容易和其他组件不兼容

4、blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];

说明此索引是只读的,原因:磁盘空间不足自动将索引设置为只读(磁盘占用95则会此状态)、或者索引状态为只读
如果空间不足解决方法:
1、释放磁盘空间,自己操作
2、在es的config的elasticsearch.yml中加入:
cluster.routing.allocation.disk.watermark.flood_stage: 99% # 设置空间阈值99%
cluster.routing.allocation.disk.threshold_enabled: false # 设置不关心磁盘空间,就算满了
3、设置索引read_only_allow_delete值为false
4、重启es
索引状态位只读:
1、设置索引read_only_allow_delete值为false
2、重启es
设置索引read_only_allow_delete值为false的方法:

注意item为你的索引名,然后返回样例:

地址:http://127.0.0.1:9200/你的索引名/_settings
参数:
{ "index.blocks.read_only_allow_delete": null }
则代表成功

分页从0开始

Error creating bean with name 'elasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]

原文地址:https://www.cnblogs.com/daihang2366/p/13772102.html