fix: 不支持es8 提示

pull/8271/head
feng626 2022-05-18 19:52:22 +08:00 committed by Jiangjie.Bai
parent c8d7c7c56f
commit 99e1b2cf92
5 changed files with 24 additions and 6 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:843b6dffe6af09073053e21f65be4c8264e6dee05509b375c8191dde8c9079b6
size 127386
oid sha256:5effe3cb5eb97d51bf886d21dfbe785bb789722f30774a6595eac7aa79b6315a
size 127478

View File

@ -4651,6 +4651,10 @@ msgstr "ターミナル管理"
msgid "Invalid elasticsearch config"
msgstr "無効なElasticsearch構成"
#: terminal/backends/command/es.py:33
msgid "Not Support Elasticsearch8"
msgstr "サポートされていません Elasticsearch8"
#: terminal/backends/command/models.py:16
msgid "Ordinary"
msgstr "普通"

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a78975a5a6669bfcc0f99bc4d47811be82a0620e873e51e4a17d06548e3b1e7f
size 105269
oid sha256:d30f8d3abc215c35bb2dd889374eeef896a193f8010ccd5ae8e27aa408f045c7
size 105337

View File

@ -4579,6 +4579,10 @@ msgstr "终端管理"
msgid "Invalid elasticsearch config"
msgstr "无效的 Elasticsearch 配置"
#: terminal/backends/command/es.py:33
msgid "Not Support Elasticsearch8"
msgstr "不支持 Elasticsearch8"
#: terminal/backends/command/models.py:16
msgid "Ordinary"
msgstr "普通"

View File

@ -28,6 +28,11 @@ class InvalidElasticsearch(JMSException):
default_detail = _('Invalid elasticsearch config')
class NotSupportElasticsearch8(JMSException):
default_code = 'not_support_elasticsearch8'
default_detail = _('Not Support Elasticsearch8')
class CommandStore(object):
def __init__(self, config):
self.doc_type = config.get("DOC_TYPE") or '_doc'
@ -68,13 +73,18 @@ class CommandStore(object):
if not self.ping(timeout=3):
return False
info = self.es.info()
version = info['version']['number'].split('.')[0]
if version == '8':
raise NotSupportElasticsearch8
try:
# 获取索引信息,如果没有定义,直接返回
data = self.es.indices.get_mapping(self.index)
except NotFoundError:
return False
info = self.es.info()
version = info['version']['number'].split('.')[0]
try:
if version == '6':
# 检测索引是不是新的类型 es6