in aliyun/log/es_migration/migration_manager.py [0:0]
def _setup_index(self, index_logstore_mappings, logstore):
indexes = index_logstore_mappings.get_indexes(logstore)
for index in indexes:
self._logger.info(
'Setup AliyunLog Logstore',
extra={'logstore': logstore, 'es_index': index},
)
try:
resp = self._es.indices.get(index=index)
except FileNotFoundError:
self._logger.error('Index not found', extra={'es_index': index})
continue
_mappings = resp[index]['mappings']
if self._es_version >= 7:
_mappings = {'': _mappings}
for mappings in _mappings.values():
index_config = MappingIndexConverter.to_index_config(mappings)
try:
self._log_client.create_index(
self._config.get('project_name'),
logstore,
index_config,
)
except LogException as exc:
if exc.get_error_code() == 'IndexAlreadyExist':
self._log_client.update_index(
self._config.get('project_name'),
logstore,
index_config,
)
continue
raise