Golang使用Elasticsearch 报错 cannot unmarshal object into Go struct field xx of type xx

"博主在尝试使用Golang与Elasticsearch交互时遇到问题,最初引用的是gopkg.in/olivere/elastic.v5,但发现教程已更新到v6。在使用gopkg.in/olivere/elastic.v6时出现json解析错误。经过排查,最终解决方法是切换到最新版本的库"github.com/olivere/elastic/v7",问题得到解决。"
摘要由CSDN通过智能技术生成

Golang使用Elasticsearch 报错

最近在学习用Golang使用Elasticsearch
按照网上的教程本地输入和命令输入都没问题
打算用网页操作,postman测试的时候报err
找了半天没发现问题

"err": "json: cannot unmarshal object into Go struct field SearchHits.hits.total of type int64"

最后改了版本
最开始网上找的的版本是gopkg.in/olivere/elastic.v5
但是文章有说现在是v6,我就用的gopkg.in/olivere/elastic.v6
报错之后改成"github.com/olivere/elastic/v7"就👌👌啦

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值