fix: 添加新的 es 时创建索引

pull/6660/head
xinwen 2021-08-17 11:20:11 +08:00 committed by Jiangjie.Bai
parent c6bb9e97fb
commit 7d7da9bf98
1 changed files with 16 additions and 3 deletions

View File

@ -76,10 +76,23 @@ class CommandStore():
self._ensure_index_exists()
def _ensure_index_exists(self):
mappings = {
"mappings": {
"properties": {
"session": {
"type": "keyword"
},
"org_id": {
"type": "keyword"
}
}
}
}
try:
self.es.indices.create(self.index)
except RequestError:
pass
self.es.indices.create(self.index, body=mappings)
except RequestError as e:
logger.exception(e)
@staticmethod
def make_data(command):