在python脚本下对获取到的json 内容存入es中,已经在try部分删除该索引名称的内容,然后再重新创建,但编译会提示该索引已经存在,进而无法往es中存入数据。
代码如下:
conn=ES(['******'],bulk_size = 10000,timeout = 20)
try:
conn.indices.delete_index('aa')
except:
pass
conn.indices.create_index('aa')
报错信息:
Exception in thread Thread-7:
Traceback (most recent call last):
File "C:\Anaconda\lib\threading.py", line 810, in __bootstrap_inner
self.run()
File "E:\xxWorkspace\BaiduMap\get_pois.py", line 61, in run
Data2ES(res)
File "E:\xxWorkspace\BaiduMap\get_pois.py", line 172, in Data2ES
conn.indices.create_index('aa')
File "C:\Anaconda\lib\site-packages\pyes\managers.py", line 165, in create_index
return self.conn._send_request('PUT', index, settings)
File "C:\Anaconda\lib\site-packages\pyes\es.py", line 486, in _send_request
raise_if_error(response.status, decoded)
File "C:\Anaconda\lib\site-packages\pyes\convert_errors.py", line 85, in raise_if_error
raise excClass(msg, status, result, request)
IndexAlreadyExistsException: [aa] already exists];
有经验的童鞋请帮忙看下。多谢
不要try,直接写
conn.indices.delete_index('aa')
conn.indices.create_index('aa')
你看看这个delete_index出错了吗
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。