python连接elasticsearch报IllegalOperation异常

在学习bobby老师的一门《python分布式爬虫打造搜索引擎》课的时候需要用python连接es数据库,结果报错如下:
elasticsearch_dsl.exceptions.IllegalOperation: Index object cannot have multiple types, doc already set, trying to assign article.

这里是因为版本不匹配的问题
查看es版本方法如下:
这里写图片描述

查看elasticsearch包与elasticsearch-dsl版本方法(pip list)如下:
这里写图片描述

因为我的es是5.1.1的版本,对应的python包应该也是5.x的。先通过pip uninstall xxx卸载对应的包,然后指定版本安装:pip install elasticsearch==5.2pip install elasticsearch-dsl==5.1

再运行代码就可以了

猜你喜欢

转载自blog.csdn.net/qq_41359051/article/details/81990319