feat: aggs remove is_text field

This commit is contained in:
yim7
2022-09-22 15:29:50 +08:00
parent 7ab7581625
commit cb6ab84d51
5 changed files with 573 additions and 57 deletions

17
opensearchorm/utils.py Normal file
View File

@@ -0,0 +1,17 @@
def parse_aggregations(data: dict, depth: int = 1):
level = data.get(str(depth), None)
if level is None:
return
if 'buckets' in level:
result = {}
buckets = level['buckets']
for b in buckets:
key = b['key']
count = b['doc_count']
children = parse_aggregations(b, depth + 1)
result[key] = children if children else count
return result
else:
value = level['value']
return value