美文网首页
spring-boot-starter-data-elastic

spring-boot-starter-data-elastic

作者: zoujiedev | 来源:发表于2020-06-15 16:23 被阅读0次

    我这里springboot使用版本为2.3.0.RELEASE,使用的elasticsearch版本为6.2.2,在进行saveAll操作时,出现如下异常信息,不单是save操作,其他操作均出现一样。

    save异常信息:
    org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=action_request_validation_exception, reason=Validation Failed: 1: type is missing;2: type is missing;3: type is missing;4: type is missing;5: type is missing;6: type is missing;7: type is missing;8: type is missing;9: type is missing;10: type is missing;11: type is missing;]

    注解document.png

    查看save的对象,上的@Document注解,发现type属性在spring-data-elasticsearch4.0以及以后被废弃,跟着说明文档进去,在elasticsearch7.0以及以后API的版本不在支持types

    官方文档.png

    因此出现type missing的异常,我猜想是spring-data-elasticsearch4.0以后,操作elasticsearch时,spring将不会带type参数,而elasticsearch6.x又必须需要这个参数,因此便出现异常。

    解决办法:
    (1)如果想继续使用elasticsearch6.x的版本,则需要将springboot版本向下调整,如使用2.1.3.RELEASE版本。
    (2)如果不想改变springboot版本则需将elasticsearch升级到7.0以及以上的版本即可。

    相关文章

      网友评论

          本文标题:spring-boot-starter-data-elastic

          本文链接:https://www.haomeiwen.com/subject/lahhxktx.html