SpringBoot2.x填坑(二):elastic search 报错{error:{root_cause:[{type:index_not_found_exception,...
执行代码
@GetMapping("searchAll")public ESDatas<DiskFile> searchAll(){DiskFile diDiskFileDto = new DiskFile();diDiskFileDto.setDiskFileId("2");diDiskFileDto.setName("张三");DiskFile diDiskFileDto1 = new DiskFile();diDiskFileDto1.setDiskFileId("1");diDiskFileDto1.setName("李四");List<DiskFile> list = new ArrayList<>();list.add(diDiskFileDto);list.add(diDiskFileDto1);esUtil.addOrUpdateDocuments("diskFile",list);ESDatas<DiskFile> esDatas = esUtil.searchAll("diskFile",DiskFile.class);return esDatas;}
页面报错
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.Tue Dec 25 16:38:25 CST 2018
There was an unexpected error (type=Internal Server Error, status=500).
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"diskFile","index_uuid":"_na_","index":"diskFile"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"diskFile","index_uuid":"_na_","index":"diskFile"},"status":404}
前言
不算是SpringBoot 2.0 的坑,只是在开发项目的时候遇到的问题总结。
控制台报错
2018-12-25 16:38:25.794 ERROR 5357 --- [nio-8089-exec-1] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/Demo] threw exception [Request processing failed; nested exception is org.frameworkset.elasticsearch.ElasticSearchException: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"diskFile","index_uuid":"_na_","index":"diskFile"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"diskFile","index_uuid":"_na_","index":"diskFile"},"status":404}] with root causeorg.frameworkset.elasticsearch.ElasticSearchException: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"diskFile","index_uuid":"_na_","index":"diskFile"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"diskFile","index_uuid":"_na_","index":"diskFile"},"status":404}at org.frameworkset.elasticsearch.handler.BaseExceptionResponseHandler.handleException(BaseExceptionResponseHandler.java:44) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.handler.ElasticSearchResponseHandler.handleResponse(ElasticSearchResponseHandler.java:61) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.handler.ElasticSearchResponseHandler.handleResponse(ElasticSearchResponseHandler.java:16) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223) ~[httpclient-4.5.6.jar:4.5.6]at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165) ~[httpclient-4.5.6.jar:4.5.6]at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140) ~[httpclient-4.5.6.jar:4.5.6]at org.frameworkset.spi.remote.http.HttpRequestUtil.sendBody(HttpRequestUtil.java:1519) ~[bboss-http-5.0.8.jar:na]at org.frameworkset.spi.remote.http.HttpRequestUtil.sendJsonBody(HttpRequestUtil.java:1477) ~[bboss-http-5.0.8.jar:na]at org.frameworkset.elasticsearch.client.RestSeachExecutor.executeRequest(RestSeachExecutor.java:161) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.client.ElasticSearchRestClient.executeRequest(ElasticSearchRestClient.java:762) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.client.ElasticSearchRestClient.executeRequest(ElasticSearchRestClient.java:726) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.client.RestClientUtil.scroll(RestClientUtil.java:1969) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.client.RestClientUtil.searchAll(RestClientUtil.java:1494) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.client.RestClientUtil.searchAll(RestClientUtil.java:1477) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at org.frameworkset.elasticsearch.client.RestClientUtil.searchAll(RestClientUtil.java:1463) ~[bboss-elasticsearch-rest-5.1.5.jar:na]at com.itunio
解决方案
- 修改为
@GetMapping("searchAll")public ESDatas<DiskFile> searchAll(){DiskFile diDiskFileDto = new DiskFile();diDiskFileDto.setDiskFileId("2");diDiskFileDto.setName("张三");DiskFile diDiskFileDto1 = new DiskFile();diDiskFileDto1.setDiskFileId("1");diDiskFileDto1.setName("李四");List<DiskFile> list = new ArrayList<>();list.add(diDiskFileDto);list.add(diDiskFileDto1);esUtil.addOrUpdateDocuments("disk_file",list);ESDatas<DiskFile> esDatas = esUtil.searchAll("disk_file",DiskFile.class);return esDatas;}
结果-成功
总结
ES在存储和查询对象时候,命名规则一定要注意 不要用“驼峰式” 命名,用 下划线“_”隔开。
贡献者
- IT实战联盟-Line
- IT实战联盟-咖啡
SpringBoot2.x填坑(二):elastic search 报错{error:{root_cause:[{type:index_not_found_exception,...相关推荐
- Docker启动Elastic Search报错 ERROR: [1] bootstrap checks failed
1. 报错 ERROR: [1] bootstrap checks failed [1]: the default discovery settings are unsuitable for prod ...
- 【android录屏填坑】录屏报错start fail,stop fail
先写个标题,有时间了填充内容. 时隔N天,终于忙完了.内容填充中-- 前言 为什么要写这么一篇文章.因为我最近做录屏实在是被坑哭了.不是遇到start fail报错,就是遇到stop fail报错,这 ...
- 微信二次分享签名错误php,微信二次分享报错invalid signature问题及解决方法
基于微信公众号开发的h5页面(使用jssdk接口),由用户A分享给用户B,用户B再次分享这个页面时,不能成功分享.问题出在用户B收到的分享链接与用户A打开的链接不同 A用户的链接为 B用户收到的连接 ...
- 小程序生成二维码报错:40169:invalid length for scene, or the data is not json string
生成二维码报错 scene的长度不合法 小程序参数scene 的长度最大32个可见字符 post提交的data不是json字符串
- LabVIEW DLL传递一个二维数组报错
LabVIEW DLL传递一个二维数组报错 当调用一个LabVIEW DLL时,首先需要声明处理程序变量并将其初始化为NULL,比如,在C中,代码如下所示: main() { /* Labvie ...
- 【已完结】【悲报】pip search 报错
文章目录 20201215 20201230更新 20210113更新 20210316更新 20210326更新 20201215 近日用pip search搜索自己写的包时,遇到了这个报错 ERR ...
- 【踩坑日记】springboot项目启动报错error create bean with name
前言 启动springboot项目报错error create bean with name xxx 以为是哪个bean没有装配上,排查了所有的bean,发现都装配了 原因分析 仔细看了报错日志,发现 ...
- git:Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists)....
Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists). 解决办法一:保 ...
- 解决MySQL报错ERROR 2002 (HY000)【转】
今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...
- 解决IntelliJ IDEA报错Error:Cannot determine path to ‘tools.jar‘ library for 17 (C:\Program Files\Java\jd
解决IntelliJ IDEA报错Error:Cannot determine path to 'tools.jar' library for 17 (C:\Program Files\Java\jd ...
最新文章
- z = x++ - --y * b/a;
- 笔记-信息系统开发基础-CMMI过程域分类-连续式的模型
- Vue3、TypeScript 实现图片数量及大小随宽度自适应调整
- mfc oninitdialog 中的hwnd == null_在SOUI中使用动态多语言切换
- G-SYNC技术是什么
- Java开发工具IntelliJ IDEA创建Andriod项目示例说明
- Codeforces 659B Qualifying Contest【模拟,读题】
- springboot vue组件写的个人博客系统
- 3D点云模型下载网站
- 基于JAVA教务排课系统计算机毕业设计源码+数据库+lw文档+系统+部署
- 如何解决ueditor乱码问题
- 用node+WebSocket+MySQL+vue仿做学习通的一些功能(一):用户登录和注册页面的实现
- 辽宁等保测评机构项目测评收费价格标准参考
- Java Instrument
- SFP光纤收发器搭配光模块的交换机连接方案解决方案
- (零基础)如何使用python下载哔哩哔哩视频?
- SparkEnv源码解读
- 【博学谷学习记录】超强总结,用心分享丨一种创新的表格
- 股票指标使用 - 捕捞季节
- springboot中怎么进行统一日志处理?
热门文章
- ffmpeg超详细综合教程——摄像头直播
- HDU - 4704(费马小定理和快速幂)
- 模拟微信发红包算法java实现
- java.io.IOException: Filesystem closed
- php redis 定时任务,利用redis实现定时任务,完全不需要crontab
- android消息发送字符串,Android aSmack-如何对文件发送进行自定义消息...
- 11g表名大小写 oracle_Oracle数据库总结
- 指数加权移动平均模型_常见收益模型
- ios苹果应用ipa一键签名工具_ios签名何以做到不越狱不上架也能安装ipa文件?
- Fiddler调式使用(一)深入研究