读取文件,获取json格式的数据doc,

然后使用 bulkRequestBuilder.add(client.prepareIndex(index, type, id).setSource(doc));

往ES中批量插入文档,接着就报下面这个异常错误:

java.lang.IllegalArgumentException: The number of object passed must be even but was [1]

 

后来,花了点时间,才查到原因:

ES 变更版本后,此处代码不适用,会报  The number of object passed must be even but was [1] 这个异常

bulkRequestBuilder.add(client.prepareIndex(index, type, id).setSource(doc)); 中的 setSource()的参数不能是json串了

但是可以转化成 map 来使用 

 

共同学习,共同进步,若有补充,欢迎指出,谢谢!

 

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2021-12-24
  • 2023-02-15
  • 2022-12-23
  • 2021-08-24
  • 2021-10-29
  • 2022-12-23
猜你喜欢
  • 2021-09-30
  • 2022-12-23
  • 2021-11-24
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案