mirror of
https://github.com/d0zingcat/opensearch-orm.git
synced 2026-05-30 15:11:11 +00:00
feat: aggs remove is_text field
This commit is contained in:
17
opensearchorm/utils.py
Normal file
17
opensearchorm/utils.py
Normal 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
|
||||
Reference in New Issue
Block a user