java测试存储数据到es时报错:...ActionRequestValidationException: Validation Failed: 1: type is missing...
/**
* 测试存储数据到 es
*/
@Test
public void indexData() throws IOException {
IndexRequest indexRequest = new IndexRequest("users");
indexRequest.id("1"); //数据的id
// indexRequest.source("username","zhangsan","age",18,"gender","男");
User user = new User();
String jsonString = JSON.toJSONString(user);
indexRequest.source(jsonString, XContentType.JSON); //要保存的内容

//执行保存操作
IndexResponse index = client.index(indexRequest, GulimallElasticSearchConfig.COMMON_OPTIONS);
//提取有用的响应数据
System.out.println(index);
}

解决:
       尝试导入以下三个依赖:

<!-- 使用elasticsearch导入的三个包 -->
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>7.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
            <version>7.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.1.0</version>
        </dependency>

有的导入上面三个包了,但还是报错,可以将版本改成7.1.0,或者尝试其他版本试一下。

最新文章

  1. css中“~”和“&gt;”是什么意思?
  2. 代码阅读工具:Source Navigator和Source Insight
  3. KendoUI系列:Window
  4. java多线程的等待唤醒机制及如何解决同步过程中的安全问题
  5. cell分割线宽度不满屏处理
  6. Working With Taxonomy Field in CSOM
  7. JavasScript判断输入框不为空
  8. extjs的combobox的用法
  9. 浅谈string
  10. 推荐15个月 Node.js 开发工具
  11. 【从翻译mos文章】Weblogic AdminServer 启动fail,报错&amp;quot;unable to get file lock, will retry&amp;quot;
  12. HDU 4081 Qin Shi Huang&#39;s National Road System 次小生成树变种
  13. 使用netflix Zuul 代理你的微服务
  14. 【一天一道LeetCode】#33. Search in Rotated Sorted Array
  15. C++学习(三十三)(C语言部分)之 队列
  16. currentTarget
  17. Web框架的原理
  18. 防盗链之URL参数签名 总结
  19. eclipse插件安装的四种方法
  20. 虚拟机中安装Ubuntu 16.04

热门文章

  1. ORACLE 遇到ORA-31693 ORA-31617 ORA-19505 ORA-27037
  2. Qt5.6使用Qt自带虚拟键盘
  3. SSL certificate problem: unable to get local issuer certificate 错误解决
  4. Redis哨兵模式+缓存穿透、击穿和雪崩
  5. python经典例题
  6. nodejs查询
  7. LightOJ - 1162 Min Max Roads
  8. pytest-2 之前后置及 conftest.py+fixture+yield实现用例前后置
  9. shell - scriptreplay timing.log output.session
  10. 日常遇到bug小记