Skip to content

Commit

Permalink
fix: mapping fallback edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
newgene committed Jul 4, 2023
1 parent eedf911 commit 0ac53e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion biothings/web/services/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ def __init__(self, mapping):
# for elasticsearch version 6.x
if len(mapping) == 1 and next(iter(mapping)) != "properties":
# remove doc_type, support 1 type per index
mapping = next(iter(mapping.values()))
# mapping in ES6 is nested under doc_type
# we will try to take the mapping dict under the first doc_type
_mapping = next(iter(mapping.values()))
if isinstance(_mapping, dict) and "properties" in _mapping:
mapping = _mapping
self.enabled = mapping.pop("enabled", True)
self.dynamic = mapping.pop("dynamic", True)
self.properties = mapping.get("properties", {})
Expand Down

0 comments on commit 0ac53e8

Please sign in to comment.