Skip to content

Commit

Permalink
check for ES7+ when updating index metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
zcqian committed Nov 1, 2021
1 parent 6b3d798 commit b6157ae
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions biothings/utils/es.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,18 @@ def update_mapping_meta(self, meta):
allowed_keys = {'_meta', '_timestamp'}
# if isinstance(meta, dict) and len(set(meta) - allowed_keys) == 0:
if isinstance(meta, dict) and not set(meta) - allowed_keys:
body = {self._doc_type: meta}
return self._es.indices.put_mapping(
doc_type=self._doc_type,
body=body,
index=self._index
)
if self._host_major_ver >= 7:
return self._es.indices.put_mapping(
index=self._index,
body=meta,
)
else: # not sure if _type needs to be specified
body = {self._doc_type: meta}
return self._es.indices.put_mapping(
doc_type=self._doc_type,
body=body,
index=self._index
)
else:
raise ValueError('Input "meta" should have and only have "_meta" field.')

Expand Down

0 comments on commit b6157ae

Please sign in to comment.