赞
踩
使用java api和elastic search进行交互时,进行到如下代码编写:
- elasticsearch:
- cluster:
- name: elasticsearch
- host: 127.0.0.1
- port: 9200
-
- SearchRequestBuilder searchRequestBuilder = this.esClient
- .prepareSearch(INDEX)
- .setTypes(TYPE)
- .setQuery(boolQueryBuilder)
- .addSort(MovieSearch.RELEASE, SortOrder.DESC)
- .setFrom(0)
- .setSize(10)
- .setFetchSource(includes, null);
抛出错误 :NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{erAdMJ4wTNGxixzYoTGhCw}{127.0.0.1}{127.0.0.1:9200}]]。
解决方案:
1、elastic search配置错误,es与java交互的默认端口号是9300,与http交互的端口号是9200,两者不要搞错了,我的就是这种情况,把application.yml配置文件里的es配置的port改为9300即可;
2、如果上述第一步骤还不起作用,则修改下es配置文件elasticsearch.yml中:
- network.host: 127.0.0.1
- cluster.name: elasticsearch
network.host即部署elastic search服务的机器ip,cluster.name可自定义,但是要和你项目中的elasticsearch.cluster.name值对应。上述两个方式可以顺利解决错误NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{erAdMJ4wTNGxixzYoTGhCw}{127.0.0.1}{127.0.0.1:9200}]]。
引申阅读: 使用quartz实现高级定制化定时任务(包含管理界面)
推荐阅读:elastic search搜索引擎实战demo:https://github.com/simonsfan/springboot-quartz-demo,分支:feature_es
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。