es爬虫 关于elasticsearch_dsl.exceptions.IllegalOperation: Index object cannot have multiple types 报错

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

这里是因为版本不匹配的问题 
查看es版本方法如下: 
es爬虫 关于elasticsearch_dsl.exceptions.IllegalOperation: Index object cannot have multiple types 报错_第1张图片

查看elasticsearch包与elasticsearch-dsl版本方法(pip list)如下: 
es爬虫 关于elasticsearch_dsl.exceptions.IllegalOperation: Index object cannot have multiple types 报错_第2张图片

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

再运行代码就可以了

你可能感兴趣的:(p,pa')