今天我将弹性搜索从1.6更新到2.1,因为1.6是易受攻击的版本,更新后我的网站无法工作,给出这个错误:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from app import app, db
File "/opt/project/app/__init__.py", line 30, in <module>
es.create_index(app.config['ELASTICSEARCH_INDEX'])
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 93, in decorate
return func(*args, query_params=query_params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 1033, in create_index
query_params=query_params)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 285, in send_request
self._raise_exception(status, error_message)
File "/usr/local/lib/python2.7/dist-packages/pyelasticsearch/client.py", line 299, in _raise_exception
raise error_class(status, error_message)
pyelasticsearch.exceptions.ElasticHttpError: (400, u'index_already_exists_exception')
make: *** [run] Error 1代码是这样的:
redis = Redis()
es = ElasticSearch(app.config['ELASTICSEARCH_URI'])
try:
es.create_index(app.config['ELASTICSEARCH_INDEX'])
except IndexAlreadyExistsError, e:
pass哪里错了?这个新版本有什么新功能?
发布于 2015-12-04 18:54:07
您将看到以下错误:index_already_exists_exception
这意味着您正在尝试创建一个已经存在的索引。第二次运行程序时,您需要先使用delete your index,或者只在程序不存在时才创建它。
发布于 2017-05-18 19:33:59
您已经使用IndexAlreadyExistsError处理了异常。尝试使用TransportError来处理异常。
您还可以添加一个检查,如:
exist = es.indices.exists(index_name)
if not exist:
es.create_index(app.config['ELASTICSEARCH_INDEX'])https://stackoverflow.com/questions/34086062
复制相似问题