我正在寻找解析 Elasticsearch 查询响应并将其转换为我自己的格式。响应可能有嵌套的桶,并且嵌套级别对于每个查询都是可变的。这是结果的简化版本:
{:bucket-aggregation
{:buckets
[{:key "outer_bucket"
:bucket-aggregation
{:buckets
[{:key "inner_bucket_1"
:bucket-aggregation
{:buckets
[{:key 1510657200000, :sum {:value 25}}
{:key 1510660800000, :sum {:value 50}}]}}
{:key "inner_bucket_2"
:bucket-aggregation
{:buckets
[{:key 1510657200000, :sum {:value 30}}
{:key 1510660800000, :sum {:value 35}}]}}
{:key "inner_bucket_3"
:bucket-aggregation
{:buckets
[{:key 1510657200000, :sum {:value 40}}
{:key 1510660800000, :sum {:value 45}}]}}]}}]}}
我想将 :value 和 :key 提取到这样的结构中:
[{:key ["outer_bucket" "inner_bucket_1" 1510657200000], :value 25}
{:key ["outer_bucket" "inner_bucket_1" 1510660800000], :value 50}
{:key ["outer_bucket" "inner_bucket_2" 1510657200000], :value 30}
{:key ["outer_bucket" "inner_bucket_2" 1510660800000], :value 35}
{:key ["outer_bucket" "inner_bucket_3" 1510657200000], :value 40}
{:key ["outer_bucket" "inner_bucket_3" 1510660800000], :value 45}]
关于我应该如何去做的任何建议?
编辑:简化所需的格式