biothings/biothings.api

Applying a diff release to ES7 indices fail

Closed this issue · 1 comments

Currently, the Syncer functionality used in BioThings Hub uses ES6 syntax in a lot of places to update metadata and mapping on the Elasticsearch index. This makes applying a diff release to fail.

Current workaround: use full releases only until this is fixed.

def update_metadata():
res = indexer.update_mapping_meta({"_meta": new_meta})
return res

def update_mapping():
diffm = os.path.join(diff_folder,
diff_mapping_file["name"])
ops = loadobj(diffm)
mapping = indexer.get_mapping()
# we should have the same doc type declared in the mapping
mapping[doc_type]["properties"] = jsonpatch.apply_patch(
mapping[doc_type]["properties"], ops)
res = indexer.update_mapping(mapping)
return res

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
)
else:
raise ValueError('Input "meta" should have and only have "_meta" field.')

Fixed via 6b3d798 and b6157ae